Get Facebook Page likes count via PHP with access_token

Today I had to figure out how to fetch again Facebook Page likes via PHP. Friends from FB changed the API and it was now saying An access token is required to request this resource. for the old API call. Accessing the data requires access_token from now on. Reading the docs I found that a page access token exists.

How to get that page access token?

First you gonna need your FB id, visit (should be the first id) Next you need to grab via API call /YOUR_FB_ID/accounts After this magic should happen and you should see access_tokens for pages you manage. Now with the access token you can get data via the following URL The output is a json which you can decode with PHP function json_decode().

I’ve got the following message: Error validating access token: Session has expired on Saturday, 20-Jun-15 00:00:00 PDT.
Token expired :/ You can check yours at
I made a never expiring page access token thanks to

FB neves expiring page access token

Author: Michal Zuber

Full stack developer, biker and rollerblader. Owner and developer at Co-founded Blog at

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s