Facebook graph api comment count

后端 未结 9 793

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_502

相关标签:
9条回答
  • 2021-02-01 20:18

    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 = ...
    
    0 讨论(0)
  • 2021-02-01 20:19

    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 ,

    0 讨论(0)
  • 2021-02-01 20:20

    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)
    
    0 讨论(0)
  • 2021-02-01 20:21

    Or to make less changes to you excisting code, use:

        $.each(json.data,function(i,fb){
        ...
           var commentsCount = 0
           if(fb.comments!=undefined){
              commentsCount=fb.comments.data.length
           }
        ...
        }
    

    commentsCount holds number of comments for active child

    0 讨论(0)
  • 2021-02-01 20:23

    Try the following:

    {
        "data": [
            {
                "id": "447235535389660_1226199",
                "from": {
                    "name": "Harjeet Walia",
                    "id": "100004980601083"
                },
                "message": "Price",
                "can_remove": false,
                "created_time": "2013-09-06T10:39:01+0000",
                "like_count": 0,
                "user_likes": false
            },
            {
                "id": "447235535389660_1226152",
                "from": {
                    "name": "Shoba Dhyani Jakhmola",
                    "id": "100000906896060"
                },
                "message": "baap re kitna mehnga !",
                "can_remove": false,
                "created_time": "2013-09-06T10:05:09+0000",
                "like_count": 0,
                "user_likes": false
            }
        ],
        "paging": {
            "cursors": {
                "after": "MQ==",
                "before": "NA=="
            }
        }
    }
    

    then

    int commentCount = <JsonNode Var with above data>.path("comments").path("data").size();
    

    Here commentCount will give the number of comments.

    0 讨论(0)
  • 2021-02-01 20:33

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

    0 讨论(0)
提交回复
热议问题