cprogcr
cprogcr

Reputation: 469

Facebook Graph API get all likes from a post

I am very new to facebook graph api, actually I just started today so I might use some help.

My code is working perfectly, I've written a simple algorithm to list people who like a certain post, but the problem is this. Here is the JSON reply I get from graph api:

<br/>
{<br/>
            "likes": {<br/>
            "data": [<br/>
               {<br/>
                   "name": "NAME",<br/>
                   "id": "ID"<br/>
               },<br/>
               {<br/>
                   "name": "NAME",<br/>
                   "id": "ID"<br/>
               },<br/>
               {<br/>
                   "name": "NAME",<br/>
                   "id": "ID"<br/>
               },<br/>
               {<br/>
                   "name": "NAME",<br/>
                   "id": "ID"<br/>
               }<br/>
           ],<br/>
  "count": 22<br/>
},<br/>
"id": "POST ID",<br/>
"created_time": "DATE CREATED"<br/>
}<br/>

so even though there are COUNT:22 Likes, the server returns only 4 names. Is it possible to get all the names? if so, how?

Upvotes: 8

Views: 30148

Answers (4)

Arij
Arij

Reputation: 100

https://graph.facebook.com/v2.4/[post_id]?fields=shares,likes.summary(true),comments.summary(true)

Facebook (v2.4+ API) counts for the post (shares + likes + comments)

added: please note, that 'albums' + 'photos' objects doesn't have shares, response from API will show you error message, that there is no such a property available on this object type.

Upvotes: 7

Prajwol Onta
Prajwol Onta

Reputation: 1478

You could do this:

https://graph.facebook.com/'.$post_id.'/comments?limit=0 // for comments
https://graph.facebook.com/'.$post_id.'/likes?limit=0 // for likes

Using facebook graph API . Hope it helps.

=========== Update: Thanks to laviksu

FQL and Graph API limit=0 change Currently, we have a bug where limit=0 returns all results. After the migration period, specifying a limit of 0 in FQL or the Graph API will return zero results.

Upvotes: 2

Saki
Saki

Reputation: 11

Use FQL like this:

SELECT user_id FROM like WHERE object_id=10151751324059927 LIMIT 1000

Now count the number of use Id-s. But it will give you like counts only till 1000 likes

Upvotes: 1

Yoav Caspi
Yoav Caspi

Reputation: 96

You can run another query on the ID of the like object asking for details (i.e. /Likes?limit=99)

Upvotes: 8

Related Questions