首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Facebook API:获得页面/群组帖子的点赞、分享、评论计数的最佳方式?

Facebook API:获得页面/群组帖子的点赞、分享、评论计数的最佳方式?
EN

Stack Overflow用户
提问于 2013-09-28 08:21:13
回答 3查看 48.3K关注 0票数 16

获得帖子的点赞、分享、评论数量的最好方法是什么?

我正在尝试通过FQL,但当URL是FB post URL时,它似乎没有提供任何数据:

SELECT like_count,comment_count,share_count FROM link_stat url="https://www.facebook.com/Macklemore/posts/10153256675935268

当我通过Graph API Explorer获得post信息时:

386050065267_10153256675935268

它给了我点赞数和分享数,我可以通过386050065267_10153256675935268/comments?summary=true获得评论数

代码语言:javascript
复制
{
  "id": "386050065267_10153256675935268", 
  "from": {
    "category": "Musician/band", 
    "name": "Macklemore", 
    "id": "386050065267"
  }, 
  "message": "We’re playing a FREE show in November to celebrate the new Microsoft Store opening in Jacksonville, Florida. Come see us! Info here: http://msft.it/STJevent\n\nThursday, November 21, 2013\n10:00 p.m.\nStart lining up for your chance to attend the show on Saturday.\nLocation: Outdoors behind Oakley, near Dick’s Sporting Goods.", 
  "actions": [
    {
      "name": "Comment", 
      "link": "https://www.facebook.com/386050065267/posts/10153256675935268"
    }, 
    {
      "name": "Like", 
      "link": "https://www.facebook.com/386050065267/posts/10153256675935268"
    }
  ], 
  "privacy": {
    "value": ""
  }, 
  "type": "status", 
  "status_type": "mobile_status_update", 
  "created_time": "2013-09-26T16:30:23+0000", 
  "updated_time": "2013-09-27T20:39:45+0000", 
  **"shares": {
    "count": 274
  },** 
  "likes": {
    "data": [
      {
        "name": "Jabson Ramos", 
        "id": "100005418486411"
      }, 
      {
        "name": "Sophia Belen Parada Andrades", 
        "id": "100002552653152"
      }, 
      {
        "name": "Oli Barrera", 
        "id": "100001718791443"
      }, 
      {
        "name": "Viktoria Martinez", 
        "id": "1697663024"
      }
    ], 
    **"count": 3345**
  }, 
  "comments": {
    "data": [
      {
        "id": "10153256675935268_43537841", 
        "from": {
          "name": "Vu Thai", 
          "id": "1338690172"
        }, 
        "message": "Sean Viray Matt Win Soo... about my birthday weekend...", 
        "message_tags": [
          {
            "id": "75311036", 
            "name": "Sean Viray", 
            "type": "user", 
            "offset": 0, 
            "length": 10
          }, 
          {
            "id": "25113189", 
            "name": "Matt Win", 
            "type": "user", 
            "offset": 11, 
            "length": 8
          }
        ], 
        "can_remove": false, 
        "created_time": "2013-09-26T16:31:03+0000", 
        "like_count": 4, 
        "user_likes": false
      }, 
      .....
    ], 
    "paging": {
      "cursors": {
        "after": "MjY=", 
        "before": "MQ=="
      }, 
      "next": "https://graph.facebook.com/386050065267_10153256675935268/comments?limit=25&after=MjY="
    }
  }
}

奇怪的是,当我在我的应用程序中运行查询时,我得不到分享计数或点赞计数。我做错了什么吗?资源管理器中的数据与应用程序可以访问的数据是否不同?

我知道我可以通过386050065267_10153256675935268/likes?summary=true得到喜欢的数量

最大的问题是股票数量的缺失。

所以总结一下,

你能通过FQL得到这些数据吗?如果没有,如何通过图形API获取份额?

EN

回答 3

Stack Overflow用户

发布于 2014-01-20 16:41:16

代码语言:javascript
复制
POST_ID?fields=likes.summary(true),comments.summary(true),shares

结果:

代码语言:javascript
复制
{
  "shares": {
    "count": 272            //share count
  }, 
  "likes": {
    "data": [

    ], 
    "paging": {

    }, 
    "summary": {
      "total_count": 3453   //like count
    }
  }, 
  "comments": {
    "data": [

    ], 
    "paging": {

    }, 
    "summary": {
      "total_count": 255    //comment count
    }
  }
}
票数 41
EN

Stack Overflow用户

发布于 2015-04-07 02:28:10

您可以使用https://graph.facebook.com/?ids=http://mycodingtricks.com之类的facebook graph api,它将返回如下所示的json代码

代码语言:javascript
复制
{  
    "http://mycodingtricks.com":{  
        "id":"http://mycodingtricks.com",
        "shares":1
    }
}

我已经开发了我自己的php脚本,你可以在上面使用api进行社交计数。http://mycodingtricks.com/share/social.php?url=YOUR-URL-HERE,它将返回如下数据:

代码语言:javascript
复制
{  
    "facebook":[  
        {  
            "share_count":1,
            "like_count":0,
            "comment_count":0,
            "total_count":1,
            "click_count":0,
            "comments_fbid":567687199998199,
            "commentsbox_count":0
        }
    ],
    "googleplus":10,
    "twitter":3,
    "buffer":0,
    "pinterest":0,
    "stumblupon":1,
    "reddit":"<html><body><h1>403 Forbidden<\/h1>\nRequest forbidden by administrative rules.\n<\/body><\/html>\n",
    "linkedin":0
}

但如果你想自己使用,这里有一篇完整的关于如何计算facebook分享,喜欢和所有的文章。http://mycodingtricks.com/php/2-ways-to-count-facebook-likes-shares-and-comments-using-php/

票数 5
EN

Stack Overflow用户

发布于 2015-03-27 10:34:37

FQL现在已折旧。下面是如何使用2.x API完成此操作:

代码语言:javascript
复制
get /1000076132681/posts?limit=3&fields=object_id,likes.summary(true),comments.summary(true)

这将生成xml,例如:

代码语言:javascript
复制
"summary": {
   "total_count": 80
 }

如果您还需要更大尺寸的图片url,请查看

代码语言:javascript
复制
?fields=full_picture,attachments
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19061937

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档