GET▾→ /v2.7▾/pepsi?fields=fan_count
I am new to graph API, I am interested in getting the facebook fan counts for different pages.
Using Facebook Graph API explorer, the above code gives me for only 1 page,
but if I want to get the fan counts for different pages – What should be the code ?
For example- I tried GET▾→ /v2.7▾/coke,pepsi?fields=fan_count
but got the error —
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: coke,pepsi",
"type": "OAuthException",
"code": 803,
"fbtrace_id": "FqAQ297ssFe"
}
}
2
Answers
Not sure why you believe this would be possible, but you need to do two API calls for two Pages. You can only make the API calls faster with batch requests, check out the docs for more information: https://developers.facebook.com/docs/graph-api/making-multiple-requests
They still count as separate API calls though, but it will be as fast as the slowest API call in the batch.
https://developers.facebook.com/docs/graph-api/using-graph-api/#multiidlookup
So the request you want to make is:
?ids=coke,pepsi&fields=fan_count
You can retrieve data for up to 50 objects in one go this way.