Open nsw2206 opened 9 years ago
the FB calls needs to be handled inside an imageview. class, not the application class. in the emulator browser session, enable popups from your play.myapp.com location.
import facebook as FB; exports = Class(ui.ImageView, function (supr) { .. .. this.build = function() { FB.onReady.run(function () { FB.init({ appId: CONFIG.modules.facebook.facebookAppID, displayName: CONFIG.modules.facebook.facebookDisplayName, // other config }); console.log("fb ready"); this.facebookReady = true; FB.getLoginStatus(function(response) { if (response.status === 'connected') { console.log('Logged in.'); } else { console.log('need log in.'); FB.login(function(response) { console.log("fb login response" + response); }); } }); // Ready to use FB! }); }; //build
some helpful pages https://developers.facebook.com/docs/javascript/
find the list of fields available for various requests https://developers.facebook.com/tools/explorer
http://permadi.com/blog/2011/04/javascript-facebook-graph-api-posting-feed-with-picture-to-walls/
from that permadi site, posting to the wall, with the increased scope request that is required. Wrap it in a FB.login request.
FB.login(function(){ FB.api('/me/feed', 'post', data, onPostToWallCompleted); }, {scope: 'publish_actions'});
..and the callback
var onPostToWallCompleted = function(response) { console.log("onposttowallcompleted" + JSON.stringify(response)); }
posting a picture to the fb wall, you need a image url. going off topic a bit here but anyways..
the image should be 158px square
Host your applications site on S3.
http://davidwalsh.name/hosting-website-amazon-s3
to resolve the issue with 403 forbidden and index.html (you'll know when you hit it)
http://stackoverflow.com/questions/27899/is-there-a-way-to-have-index-html-functionallity-with-content-hosted-on-s3 ... For people still struggling against this after 3 years, let me add some important information:
The URL for your website (and to which you have to point your DNS) is not
For a specific example, consider:
http://www-example-com.s3-website-us-west-2.amazonaws.com/ works http://www-example-com.s3.amazonaws.com/index.html works http://www-example-com.s3.amazonaws.com/ fails with 403 Forbidden To get your true website URL, go to your S3 Management Console, select the target bucket, then Properties, then Static Website Hosting. It will show the website URL (you'll can even click!) that will work.
This can also be done from the aws cli. Here is a complete cli transcript of recreate www.example.com on Amazon S3:
compiled into android release, error on posting was key hash xxxx does not match application hashes. add the string specified with an = sign at the end to the android key hash.
"addons": { "facebook": { "facebookAppID": your-app-id, "facebookDisplayName": your-app-display-name, } }
In the facebook developers site https://developers.facebook.com/apps/
go to your app, or "add a new app" if you dont have one already.
in your app, there is getting started - click there. It opens the same wizard as "add a new app"
chose the www option
add a site url eg http://play.myapp.com/ click next - that should be enough to save the setting.
now you need to go to settings / basic. you will see the website div appears now.
add the site url you've set up to the App Domains setting.
now to configure local environment to suit.
add a hosts entry to use for emulator access eg - if your running the emulator on the same PC as developing 127.0.0.1 play.myapp.com
use the new address to hit the emulator
http://play.myapp.com:9200/
good to go :)