Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook graph api comment count

seems Facebook changed the result of posts, few weeks ago it was possible to read the comment count from the post directly

https://graph.facebook.com/125909647492772_502974003098530

you got something like

...
"comments": {
"data": [
  {
    "id": "502974003098530_78616446", 
    "from": {
      "name": "Mathias Fritz", 
      "id": "526559276"
    }, 
    "message": "saugeil!", 
    "can_remove": false, 
    "created_time": "2013-03-26T14:58:01+0000", 
    "like_count": 1, 
    "user_likes": false
  }
], 
"paging": {
  "cursors": {
    "after": "MQ==", 
    "before": "MQ=="
  }
}, 
"count": 1

but now the count is missing.

I did some research on the graph documentation but the only change in that direction seems to be that comments can have comments now... and those comments are counted in a field named comment_count.

Is there still a way to get the total comment count?

like image 241
fuchs777 Avatar asked May 03 '13 11:05

fuchs777


People also ask

How do you count comments on Facebook?

Use the FB comments box tool to check the number of comments for a specific URL. Facebook uses social signals to display high quality and most relevant comments for each user. When a user selects the option post to Facebook, friends can see the comment / story inside their news feed.

Is Facebook graph API deprecated?

API Version Deprecations: As part of Facebook's Graph API and Marketing API, please note the upcoming deprecations: August 3, 2021: Graph API v3. 3 will be deprecated and removed from the platform. August 25, 2021 Marketing API v9.

How do I count comments in a Facebook group?

Clicking the Comments tab displays the total number of comments and the Reactions tab reveals the total reactions for the time period. Remember that when people visit your Facebook group, they want to feel welcome.

What data can I get from Facebook graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.


6 Answers

To get the count, add ?summary=1 at the end: https://graph.facebook.com/125909647492772_502974003098530/comments?summary=1

like image 194
Veerle Struyf Avatar answered Oct 16 '22 23:10

Veerle Struyf


I was having same problem, just adding likes.summary(true),comments.summary(true) in parameter in against "fields" worked for me.

e.g. I used https://graph.facebook.com/me/feed?access_token=ACCESS_TOKEN&fields=story,from,story_tags,likes.summary(true),comments.summary(true)

instead of https://graph.facebook.com/me/feed?access_token=ACCESS_TOKEN

Also you can add other parameters if you want; separated by a ,

like image 28
Shirish Herwade Avatar answered Oct 16 '22 22:10

Shirish Herwade


summary=true is what you are looking for

Get likes count :

114916098537132_1265715836790480/likes?summary=true

Get comments count

114916098537132_1265715836790480/comments?summary=true

Get shares count :

114916098537132_1265715836790480?fields=shares

And last [ combining all 3 ]

114916098537132_1265715836790480?fields=shares,likes.summary(true),comments.summary(true)

Improved version ( add limit(0) to removes list of likes and get only summary ):

114916098537132_1265715836790480?fields=shares,likes.limit(0).summary(true),comments.limit(0).summary(true)
like image 26
Abhishek Goel Avatar answered Oct 16 '22 23:10

Abhishek Goel


This works perfectly with me:

fields=shares,created_time,comments.summary(true).limit(0)

This return comments count at summary and return 0 comments at the same time which is perfect as you only need the comment count.

like image 33
Mahmoud Hanafy Avatar answered Oct 16 '22 23:10

Mahmoud Hanafy


You can get total comment count via FQL. See this question below as reference:

Facebook API - comment count via FQL

Here's the query you need: SELECT comment_info FROM stream WHERE post_id = ...

like image 5
Cormac Driver Avatar answered Oct 16 '22 23:10

Cormac Driver


If you'd like to count everything on Facebook. (That number is visible for Facebook's User)

You should use FQL (Facebook Query Language) instead of Graph API.

Facebook Query Language Reference

This situation you should to query

SELECT comment_info FROM stream WHERE post_id = ...
like image 3
Kiattisak Anoochitarom Avatar answered Oct 16 '22 21:10

Kiattisak Anoochitarom