问题
Currently I am using desktop windows service to download my Facebook page insights/ page likes/friends etc. graph data . so, for that i have added app on my facebook page and generated full permission offline access token. so, using that i am downloading my facebook page insights properly from last one year.
But, as Facebook deprecated offline acccess token.
Please anyone can help me how i can generate Access Token with full permission to download my page insight data without signing in (witout any User/Ui dialog (allow etc.)).
Right now , i am trying & going through some api to generate that access token as following : - https://graph.facebook.com/oauth/access_token?client_id=xxxx&client_secret=xxxxx&grant_type=client_credentials
But , using above call i am getting access token (short length token) - e.g : -
123484913842345|jkioEjsRAhFrNdertg9zuxPiopl
Using above access token getting following error when try to see graph data : -
{"error": {"message": "Unsupported get request.","type": "GraphMethodException","code": 100 }}
But, i have found that this access token does not have full permissions & also short life.
When I have used my old offline access token then it is giving response properly. (this token will be off after some duration). so, to generate same type of Access token with around 60 day life. Please help me on this. How i can generate access token with full permission with full 110 character length. Also, i am using windows service so , anyone can help on this how to generete access token without signing in (User/UI activity)
回答1:
To fix this you need to extend the short lived token.
You can also debug the access token without any user interaction to see if the action of extending the access token worked.
This link is a good reference about the expiration of offline access.
When you debug the access token using this url:
https://graph.facebook.com/debug_token?input_token=INPUT_TOKEN&access_token=ACCESS_TOKEN
INPUT_TOKEN is the user access token
ACCESS_TOKEN is the app access token which is formed like so: APP_ID|APP_SECRET
To clarify on that, If my app id is 123
& the app secret is abc
then the app access token is 123|abc
回答2:
Simple solution just call following functions using PHP SDK
$facebook->setExtendedAccessToken();
and after it get extented access token through
$access_token = $facebook->getAccessToken();
OR
GET /oauth/access_token?
grant_type=fb_exchange_token&
client_id={app-id}&
client_secret={app-secret}&
fb_exchange_token={short-lived-token}
来源:https://stackoverflow.com/questions/15187604/facebook-full-permission-accesstoken-alternative-to-offline-access-token