如何从facebook图php api v2.6获得总页面赞

时间:2016-06-08 14:18:16

标签: php facebook facebook-graph-api facebook-insights

我正在尝试使用以下方法获取总页面数

$response = $fb->get('/{page_id}/insights/page_fans', $_SESSION['fb_access_token']);
         $data = $response->getDecodedBody();

但是我得到了像

这样的输出
{
  "data": [
    {
      "name": "page_fans",
      "period": "lifetime",
      "values": [
        {
          "value": 4950,
          "end_time": "2016-06-04T07:00:00+0000"
        },
        {
          "value": 4951,
          "end_time": "2016-06-05T07:00:00+0000"
        },
        {
          "value": 4954,
          "end_time": "2016-06-06T07:00:00+0000"
        }
      ],
      "title": "Lifetime Total Likes",
      "description": "Lifetime: The total number of people who have liked your Page. (Unique Users)",
      "id": "5440223423423f216075/insights/page_fans/lifetime"
    }
  ],
  "paging": {
    "previous": "https://graph.facebook.com/v2.6/123/insights/page_fans?access_token=EAACEdEose0cBAPZCXGPTTelvenkGYIwiZAbT4N26ZB97KwDvbi9TfoyvkeET8WLiSbVHS7k3FsQL5w5DFJK5mAus0XA1123TPaPBEpxhdUq123ZAx1r7B3wIVjJVjLk2jrVu1M8apfBndmz9FUviAzWRpR4vHRgBYcSxEn4JXcioASljYLwZDZD&debug=all&format=json&method=get&pretty=0&suppress_http_code=1&since=1464617613&until=1464876813",
    "next": "https://graph.facebook.com/v2.6/123/insights/page_fans?access_token=EAACEdEosDe0cBAPZCXG123PTTelvenkGYIwiZAbT4N26ZB97KwDvbi9TfoyvkeET8WLiSbVHS7k3FsQL5w5JK5mAus0XATPaPBEpxhdUqZAx1r7B3wIVjJVjLk2jrVu1M8apfBndmz9FUviAzWRpR4vHRgBYcSxEn4JXcioASljYLwZDZD&debug=all&format=json&method=get&pretty=0&suppress_http_code=1&since=1465136013&until=1465395213"
  }
}

但我需要完全喜欢的网页。我们可以这样做吗

使用FQL的旧方法 - select fan_count from page where page_id = page_id;但我正在尝试使用最新的api v2.6

2 个答案:

答案 0 :(得分:0)

  

[来自评论]我需要在Facebook页面上显示的总页面颜色

那么你不应该开始使用insights边缘,而只是

/page-id?fields=fan_count

答案 1 :(得分:0)

您可以使用

获得页面的总点赞数
/page_id?fields=new_like_count

如果你想获得页面的帖子喜欢使用

/page_id?fields=posts{likes.summary(true)}