dev-m
dev-m

Reputation: 460

Getting like and comment counts per post of facebook page by graph api version 2

I have been getting like and comment counts per post of facebook page/group feed call by graph api separately using FQL but as version 2 of graph api released fql no longer working to serve purpose.

So i have to find new ways to get comment and like counts per post of page feed display. I will make a separate call to get comment and like counts per post of the fb page as it may not be possible to get things in same page feed call(or it is?).

So, searching through google, i found following way using graph api call -

..page_id/feed?fields=likes.limit(1).summary(true){id},comments.limit(1).summary(true)&limit=10

Is this the best and error free way?? Also besides id and summary fields i also get created_time, paging, likes data by the above call which is unexpected and redundant, how do i exclude these additional fields?

So please any FB employee show me light on what is the best way to retrieve like and comment count per post of page/group feed using graph api version 2.

Upvotes: 5

Views: 3748

Answers (1)

Akshay Khale
Akshay Khale

Reputation: 8361

If you want to retrieve Likes and comments count of a post on FB you can achieve this by using Id of the post Like this

..Your_Post_ID?fields=likes.limit(0).summary(true),comments.limit(0).summary(true)

the result will contain Total numbers of likes of the post, total numbers of comments of the post, post ID and post created time.

The result will be like this

{
  "likes": {
    "data": [
    ], 
  "summary": {
    "total_count": 550
   }
  }, 
  "comments": {
    "data": [
    ], 
    "summary": {
    "order": "chronological", 
    "total_count": 858
    }
  }, 
  "created_time": "2014-10-12T05:38:48+0000", 
  "id": "Your_Post_ID"
}

Upvotes: 6

Related Questions