ChatGPT解决这个技术问题 Extra ChatGPT

Facebook Access Token for Pages

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...

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 } });`
You can get a permanent token: stackoverflow.com/questions/17197970/…

i
ifaour

Go to the Graph API Explorer Choose your app from the dropdown menu Click "Get Access Token" Choose the manage_pages permission (you may need the user_events permission too, not sure) Now access the me/accounts connection and copy your page's access_token Click on your page's id Add the page's access_token to the GET fields Call the connection you want (e.g.: PAGE_ID/events)


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?
I've climb mountains and swim oceans just seek for this answer. Thank you.
This process doesn't work anymore as the access token generated expires when you log out for whatever reason.
@coneybeare, please refer to this document on how to extend the page access token
I keep getting an empty result. Does it make a difference if it is an app page?
R
Robin Layfield

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."


This does not help with getting events for a restricted page.
Is that still true?!
A
Anthony

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