在php中检索Facebook帖子


Retrieving likes of Facebook Posts in php

我正在寻找一种方法,根据帖子id来检索Facebook帖子的点赞数。我从这个论坛上得到了一个php代码。。它有点像

 <?php
    function fetchUrl($url){
       return file_get_contents($url);
   }        
    $json_object = fetchUrl("https://graph.facebook.com/{post_id}/likes?access_token={token}&limit=5000000"); // 
    $feedarray   = json_decode($json_object, true);
    $likesNum = count($feedarray['data']); // return the number of items in `data` array
    print $likesNum;
?>

但问题是,这种方法无法检索帖子的总点赞数,因为点赞以1000个为一个块显示,之后会有另一个链接到另一个页面,其中包含下一组1000个点赞,以此类推

有没有一种方法可以通过一个查询获得facebook帖子的总点赞数?

添加摘要标志**summary=true**

"https://graph.facebook.com/{post_id}/点赞?access_token={token}&summary=true"

{
  "data": [
    {
      "id": "663342380429664",
      "name": "Luis Mendoza"
    },
    {
      "id": "1532100840406448",
      "name": "Sakazuki Akainu"
    },
    {
      "id": "780666205412913",
      "name": "Joaito KoRn"
    },
    {
      "id": "1060933433919925",
      "name": "Adrian Sosa"
    },
    {
      "id": "860704407276452",
      "name": "Sarah Rosenstrauch"
    },
    {
      "id": "1947974762009431",
      "name": "David Prieto"
    },
    {
      "id": "804864302928112",
      "name": "Ronal Ortega"
    },
    {
      "id": "1505075359814934",
      "name": "Gonzalo Larzen"
    },
    {
      "id": "1431207613804483",
      "name": "Victor Clc"
    },
    {
      "id": "508785009283633",
      "name": "Rxdry EzDe Cerrx Mcmxii"
    },
    {
      "id": "435355413265946",
      "name": "Ángel Fernando Huillca Alonso"
    },
    {
      "id": "163773913961445",
      "name": "Pelado Miguel Pin Macias"
    },
    {
      "id": "1479227465674392",
      "name": "Releck Solitario"
    },
    {
      "id": "161610054193539",
      "name": "MD Sahin MD Sahin"
    },
    {
      "id": "798431050242097",
      "name": "Brian Nahuel"
    },
    {
      "id": "624869574305480",
      "name": "Saul Alfredo"
    },
    {
      "id": "1642733362665392",
      "name": "Junior Zurita"
    },
    {
      "id": "134907406871404",
      "name": "Wil Peña"
    },
    {
      "id": "10153052770952668",
      "name": "Miguel Peña Cáceres"
    },
    {
      "id": "1461494580846182",
      "name": "Darian Suarez"
    },
    {
      "id": "365762500250317",
      "name": "Igarashi Ganta"
    },
    {
      "id": "750032685093387",
      "name": "Camila Barbé"
    },
    {
      "id": "781013541941152",
      "name": "Gonzalo Nievas"
    },
    {
      "id": "756520927743339",
      "name": "Jonathan C. Duran Cuellar"
    },
    {
      "id": "1504488093199860",
      "name": "Maxi Russo"
    }
  ],
  "paging": {
    "cursors": {
      "before": "NjYzMzQyMzgwNDI5NjY0",
      "after": "MTUwNDQ4ODA5MzE5OTg2MAZDZD"
    },
    "next": "https://graph.facebook.com/v2.3/1009501939072385/likes?access_token=TOKEN..."
  },
  "summary": {
    "total_count": 4303
  }
}