Skip to content

Instantly share code, notes, and snippets.

@joelongstreet
Last active October 13, 2015 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joelongstreet/4125083 to your computer and use it in GitHub Desktop.
Save joelongstreet/4125083 to your computer and use it in GitHub Desktop.
Request an access token from facebook and then use it to make a subsequent request.
request = require 'request'
facebook = require 'fb'
get_fb_data = (req, res, next) ->
fb_req = 'https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECCRET&grant_type=client_credentials'
request.get fb_req, (err, res, body) ->
if err then console.log err
else
token = body.split('access_token=')
facebook.setAccessToken(token[1])
facebook.api '7145472124/feed', (response) ->
console.log response.data
module.exports = get_fb_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment