How to create-extend access token for Facebook pages
1st of all you have to create an app where we will allow permissions like manage_pages and read_insights etc to have full access to pages tokens etc from that app. So let’s start and try to make it as simple as we can.
1- Create an App.
2- Click on Permissions link. Add the permissions like manage_pages, read_insights etc in the Extended permissions text box and Save.
3- Go to graph explorer and select the app we just created from the dropdown. Click on the get access token button. Check necessary permissions like in step 2.
4- Type this in Graph API me/accounts and it will show all the pages which this user/account administrator of with info like access_token etc.
5- Copy the access token and use it in your PHP scripts for that page. Now you will be able to pull that page data like total likes, total dislikes etc using insights etc.
By default the access token will last for few hours, and for pages we need to have long session for that token.
Extend the access_token by using this url:
APP_ID = The app id we granted permissions like manage_pages, read_insights etc.
APP_SECRET = The app secret we granted permissions like manage_pages, read_insights etc.
PAGE_TOKEN = The token of the page we want to extend.
After extending, facebook will issue new access_token, use that in the script. The new extended token will have 2 months time.
Check page access_token validity by using debug url:
Input the page access_token in the text box.
I will be writing another article on how to use the above app, page details in PHP and pull some page data. Stay tuned.