php - Facebook API : best way to get like, 共享,页面/群组帖子的评论计数?

标签 php facebook facebook-graph-api facebook-fql

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

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

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

当我通过 Graph API Explorer 获取帖子信息时:

386050065267_10153256675935268

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

获取评论数
{
  "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 获取共享计数?

最佳答案

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

结果:

{
  "shares": {
    "count": 272            //share count
  }, 
  "likes": {
    "data": [

    ], 
    "paging": {

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

    ], 
    "paging": {

    }, 
    "summary": {
      "total_count": 255    //comment count
    }
  }
}

关于php - Facebook API : best way to get like, 共享,页面/群组帖子的评论计数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19061937/

相关文章:

facebook - 将 Facebook 名称转换为身份证号码

PHP - 这个 Levenshtein 距离递归算法太慢了还是我错了?

Facebook SDK - 无法关闭 iOS6 登录弹出窗口

ruby-on-rails - Facebook Canvas 应用程序重定向到 Facebook Logo

php - 如何通过 API (Php SDK) 以管理员身份发布到 Facebook 页面?

facebook-graph-api - 如何使用facebook api分享页面帖子

PHP MySQL 注释

php - 当我尝试使用 Laravel Controller 方法处理 AJAX 请求时,为什么会出现此异常?

PHP:如何使用 Snappy(wkhtmltopdf 包装器)

php - Laravel 社交名流 : InvalidStateException