Reputation: 1633
I have created the page in facebook and I would like to get facebook stats daily using graph API.
I can get access token by using facebook explorer tools , but it is expired shortly.
I need long live access token to get insights details by using graph API. It would help to get facebook stats daily. If anyone knows it, please share your suggestions.
Thanks in advance!
Upvotes: 1
Views: 2439
Reputation: 10784
Follow facebook docs to get long-lived user access token
curl -i -X GET "https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&
client_id=APP-ID&
client_secret=APP-SECRET&
fb_exchange_token=SHORT-LIVED-USER-ACCESS-TOKEN"
Upvotes: 0
Reputation: 20753
Read about the tokens here: https://developers.facebook.com/docs/facebook-login/access-tokens
Get the user access token with manage_pages
permission
Extend the user access token as explained in here: https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension
Use the above token and get the page access token using /v2.5/{page-id}?fields=access_token
The token you get here wont expire.
Upvotes: 0
Reputation: 591
You will need to gather the access token from your user with permission 'manage_pages'.
Then you can use this request
GET /oauth/access_token?
grant_type=fb_exchange_token&
client_id={app-id}&
client_secret={app-secret}&
fb_exchange_token={short-lived-token}
to obtain a long living page access token. Use this for your statistics.
Upvotes: 0