Created
April 22, 2013 13:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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