Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get fan page likes count using graph api?

How can I get fan page likes count using graph api? Earlier it was here:

https://graph.facebook.com/FANPAGE_ID/?access_token=ACCESS_TOKEN

but now it's return only:

{
   "name": "Fanpagename",
   "id": "0000000000"
}
like image 304
user3115655 Avatar asked Dec 05 '22 21:12

user3115655


2 Answers

For the graph api version 2.7, the term to get likes count is changed, Now you will have to write

https://graph.facebook.com/FANPAGE_ID?access_token=ACCESS_TOKEN&fields=name,fan_count

FANPAGE_ID can be the username or the page_id of any fb page. ACCESS_TOKEN must be replaced with access token.

like image 93
stackMonk Avatar answered Jan 18 '23 12:01

stackMonk


You need to add the fields you want to get now:

https://graph.facebook.com/FANPAGE_ID?access_token=ACCESS_TOKEN&fields=name,likes

Serach for "Declarative Fields" in the changelog: https://developers.facebook.com/docs/apps/changelog#v2_4

Edit: Since v2.7 of the Graph API, "likes" has been renamed to "fan_count". More information: https://developers.facebook.com/docs/apps/changelog

The would be the new API call:

https://graph.facebook.com/FANPAGE_ID?access_token=ACCESS_TOKEN&fields=name,fan_count
like image 42
andyrandy Avatar answered Jan 18 '23 11:01

andyrandy