Skip to content

Instantly share code, notes, and snippets.

@dai-shi
Created April 22, 2013 13:33
Show Gist options
  • Save dai-shi/5434902 to your computer and use it in GitHub Desktop.
Save dai-shi/5434902 to your computer and use it in GitHub Desktop.
A sample code to get an application access token using Thuzi / facebook-node-sdk.
var FB = require('fb');
FB.api('oauth/access_token', {
client_id: process.env.FACEBOOK_APP_ID,
client_secret: process.env.FACEBOOK_SECRET,
grant_type: 'client_credentials'
}, function(res) {
if (!res || res.error) {
console.log('error occurred when getting access token:', res && res.error);
return;
}
console.log('set application access token:', res.access_token);
FB.setAccessToken(res.access_token);
});
function getFeed() {
FB.api('hoge/feed', function(res) {
if (!res || res.error) {
callback(res ? res.error : 'unknown error');
return;
}
console.log(res);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment