0

I want to get likes on post on the page: "The Jungle Book"

I am able to get the likes of the page using url:

https://graph.facebook.com/" + pageId + "?fields=likes&access_token=" + ACCESS_TOKEN   

I have read the documentation and find that i will get the likes(total count) of the post only returned when the flag summary=true is set
The response should look like this

{
   "likes": <somecount>,
   "id": "151505938209071_1507814655911519"
}

I am able to get the likes on page but not able to get total number of likes on the particular post on that page.
Can anyone help me regarding how I should set the URL or is there any other way to do it.

ojas
  • 247
  • 1
  • 4
  • 17

1 Answers1

0

From what you described it sounds like it should be like this:

https://graph.facebook.com/" + pageId + "?fields=likes&summary=true&access_token=" + ACCESS_TOKEN   

The above is your existing URL with summary=true in between the fields=likes and access_token parameters


However you may be interested in this answer

Quote:

Couldn't find this in the documentation but multiple calls to the API are not necessary. You can use summary when querying a feed or multiple posts. Specify this in the fields parameter.

https://graph.facebook.com/PAGE_ID/feed?fields=comments.limit(1).summary(true),likes.limit(1).summary(true)

This will return a response like this.

{
  "data": [
    {
      ....
      "summary": {
        "total_count": 56
      }
      ...
    }, 
    {
      ....
      "summary": {
        "total_count": 88
      }
      ...
    }
  ]
}

This will be much faster than making individual requests for each object just to get the number of comments or likes.

Community
  • 1
  • 1
Tim Penner
  • 3,551
  • 21
  • 36
  • Actually by doing this , i will get the names and id of people who liked that post but i need the total count of people who liked that post...e.g. { "likes": 867839, "id": "151505938209071" } – ojas Apr 02 '16 at 16:56
  • I can count but it will be unnecessary overhead... i will do that in worst case but if there's a thing exists from which i can get total count from API then it will be great – ojas Apr 02 '16 at 17:37
  • Yes @Tim but its giving response like this: { "data": [ ] } here is my url link](https://graph.facebook.com/151505938209071_1507694925923492/feed?fields=comments.limit(1).summary(true),likes.limit(1).summary(true)).... The real post has 1.2k likes – ojas Apr 02 '16 at 18:22
  • @ojas What about `https://graph.facebook.com/POST_ID/likes?summary=true&access_token=XXXXXXXXXXXX` where it is `likes` instead of `feed` – Tim Penner Apr 03 '16 at 03:18
  • Exception is coming while trying with above url: Syntax error \"Expected end of string instead of \"?\".\" at character 5: likes?summary=true – ojas Apr 03 '16 at 23:49