Skip to content

Instantly share code, notes, and snippets.

@denwwer
Forked from dai-shi/facebook-node-sdk-sample.js
Created November 21, 2017 10:44
Show Gist options
  • Save denwwer/3e3dd888317fdcf6f27ad79c46aef9ca to your computer and use it in GitHub Desktop.
Save denwwer/3e3dd888317fdcf6f27ad79c46aef9ca 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