124

I have a Facebook Page that I want to get some things from it. First thing are feeds and from what I read they are public (no need for access_token). But I want to also get the events... and they aren't public and need the access_token.

I don't want the user to login in Facebook or anything like that. I just want to push all the data I can from this only page. That's why I already discarded many examples I found here and the one at https://developers.facebook.com/blog/post/500/ , because they want the user to login or require some user action I'm not interessed.

What I want is that my Facebook Application have full authorization and access_token to push the data from this one Facebook Page that I own (admin). Is this possible? I already tried many things but nothing seems to work.

I tried clicking at this: https://www.facebook.com/dialog/oauth?client_id=150635421702954&redirect_uri=http://MY_URL/&scope=manage_pages&response_type=token&fields=access_token - changing MY_URL to my site's and it requests authorization to edit every page I own. Even not being what I want I clicked but had no access_token in return...

2
  • To get events I do this now (the access_token expires a lot): 1 - Get a token from the Graph Explorer 2 - Paste it in my code below: var authToken = 'THE_CODE_I_GOT'; var feedQuery = 'graph.facebook.com/MY_PAGE_ID/feed'; var feedURL = feedQuery +'?access_token='+ authToken +'&callback=?'; $.getJSON(feedURL,function(data){ var d = data.data; for( i=0; i < d.length; i++) { d[i].message ? $("#list").append('<li>'+ d[i].message +'</li>') : ''; // lots of other stuff, you got it } });` Nov 22, 2011 at 18:40
  • 1
    You can get a permanent token: stackoverflow.com/questions/17197970/…
    – Josh
    Oct 25, 2013 at 3:19

3 Answers 3

273
  1. Go to the Graph API Explorer
  2. Choose your app from the dropdown menu
  3. Click "Get Access Token"
  4. Choose the manage_pages permission (you may need the user_events permission too, not sure)
  5. Now access the me/accounts connection and copy your page's access_token
  6. Click on your page's id
  7. Add the page's access_token to the GET fields
  8. Call the connection you want (e.g.: PAGE_ID/events)
20
  • 2
    By doing this I'm able to call connections on all my pages by using a page token of only one of them. Isn't this wrong? Is there a way to get a token for just one specific page that doesn't work on the other pages?
    – andresp
    Aug 21, 2012 at 22:32
  • 118
    I've climb mountains and swim oceans just seek for this answer. Thank you.
    – IMB
    Nov 22, 2012 at 17:08
  • 16
    This process doesn't work anymore as the access token generated expires when you log out for whatever reason.
    – coneybeare
    Jan 6, 2013 at 17:24
  • 1
    @coneybeare, please refer to this document on how to extend the page access token
    – ifaour
    Jan 10, 2013 at 11:55
  • 1
    I keep getting an empty result. Does it make a difference if it is an app page?
    – Max
    Jul 16, 2014 at 17:25
16

See here if you want to grant a Facebook App permanent access to a page (even when you / the app owner are logged out):

http://developers.facebook.com/docs/opengraph/using-app-tokens/

"An App Access Token does not expire unless you refresh the application secret through your app settings."

2
  • 6
    This does not help with getting events for a restricted page.
    – Sinan
    Jan 21, 2013 at 13:53
  • 2
    Is that still true?!
    – jeromej
    Feb 7, 2018 at 8:51
5

The documentation for this is good if not a little difficult to find.

Facebook Graph API - Page Tokens

After initializing node's fbgraph, you can run:

var facebookAccountID = yourAccountIdHere 

graph
.setOptions(options)
.get(facebookAccountId + "/accounts", function(err, res) {
  console.log(res); 
});

and receive a JSON response with the token you want to grab, located at:

res.data[0].access_token

Not the answer you're looking for? Browse other questions tagged or ask your own question.