31

When I try to get all my "likes" (formerly fan pages) on Facebook Graph API, sometimes it returns me an empty set:

{
   "data": [

   ]
}

I tried with https://graph.facebook.com/me/likes?access_token=MY_ACCESS_TOKEN and with graph.facebook.com/vinch/likes?access_token=MY_ACCESS_TOKEN but the result is exactly the same (empty).

Any idea of what it can be? I need it to know if a user likes (is fan of) a specific page.

Kara
  • 6,115
  • 16
  • 50
  • 57
Vinch
  • 1,551
  • 3
  • 13
  • 15
  • Hi. I am having the same issue. Have you found a solution for the same? I am trying the get the likes of a user, using the graph api example it works. But if i try my access_token and $facebook->api('/me/likes') i get empty array. – codingbbq Mar 04 '11 at 08:23
  • I am having this problem at the moment for only certain users and only in google chrome (mac or pc). – thomallen Apr 19 '11 at 23:17
  • I've noticed this problem for at least 3 months now. For some users, Facebook simply returns empty data even though they have likes. Incredibly annoying, and I had to scrap functionality from my projects because of it. – Steven Mercatante Apr 28 '11 at 17:33
  • I have the similar issue in facebook android api while getting the list of friends for user. 'user_friends' permission is these but reruns an empty set. Response is {Response: responseCode: 200, graphObject: {"data":[],"summary":{"total_count":1352}}, error: null} – Madusanka Apr 09 '17 at 06:37

8 Answers8

20

add user_likes permission to your application

Omar
  • 216
  • 2
  • 2
  • 1
    Yeah, this is actually the solution! – Vinch Jan 31 '12 at 01:34
  • Where is this permission added? – Adam Nuttall Jun 14 '12 at 11:20
  • It seems you can define this [permission](https://developers.facebook.com/docs/authentication/permissions/) during the [authentication process](https://developers.facebook.com/docs/authentication/). – Stéphane Jun 20 '12 at 09:26
  • I have the similar issue in facebook android api while getting the list of friends for user. 'user_friends' permission is these but reruns an empty set. Response is {Response: responseCode: 200, graphObject: {"data":[],"summary":{"total_count":1352}}, error: null} – Madusanka Apr 09 '17 at 06:37
5

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": [

   ]
}
Mike Bretz
  • 1,956
  • 18
  • 19
4

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

Augustus Francis
  • 2,694
  • 4
  • 22
  • 32
0

Yesterday facebook fixed likes (http://developers.facebook.com/live_status#msg_612)

You can get only user likes not object likes. For example, you can not get all users by page_id.

Valery Viktorovsky
  • 6,487
  • 3
  • 39
  • 47
0

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.

jhchen
  • 14,355
  • 14
  • 63
  • 91
0

My test user had approved my app before the likes permission had been granted so it was never picking up the likes authorisation. By removing the app from the test user's profile and authorising again I was able to get their likes.

Brian F
  • 1,620
  • 1
  • 19
  • 23
0

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

Kartik kar2905
  • 56
  • 1
  • 10
0

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

Dai Nguyen
  • 69
  • 6