When I try to get all my \"likes\" (formerly fan pages) on Facebook Graph API, sometimes it returns me an empty set:
{
\"data\": [
]
If all you need to know is whether or not a user is a fan of something (and not a list of likes or a list of fans) this should do the trick: http://developers.facebook.com/docs/reference/rest/pages.isFan.
add user_likes permission to your application
You can't get the likes of a fan page through the API. Follow this bug for more info: http://bugs.developers.facebook.net/show_bug.cgi?id=12880
You cannot get likes
of a post
because of permission concern problem.
https://developers.facebook.com/docs/graph-api/reference/v4.0/object/likes#readperms
I read in the Changelog of 2010-12-12:
GET [page-id]/members/[user-id] will return the individual user if he or she is a fan of the page (Graph API equivalent of pages.isFan) (rE322057)
So, you can check with Graph API if a known user_id is fan of a known page_id with exactly this syntax. You need to supply a valid access_token. With the fields parameter you can choose, what the API should return. E.g. append "&fields=id,name,picture" to get the id, name and picture in case the user is a fan.
{
"data": [
{
"id": "712084216",
"name": "Mike Bretz",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs842.snc4/70441_712084216_5491098_q.jpg"
}
]
}
You'll get an empty result if the user is not a fan
{
"data": [
]
}
If you are using Graph API Explorer. you can set permissions by taking get Access Token Button on the Top and specify user_likes and click ok.. Try your code again..
Hope this helps