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:

https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=fb_exchange_token&fb_exchange_token=PAGE_TOKEN

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:

https://developers.facebook.com/tools/debug/access_token

Input the page access_token in the text box.