【发布时间】:2015-11-18 20:13:00
【问题描述】:
我正在寻找一种方法来根据其 post_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 个点赞数的不同页面,依此类推。
p>有没有一种方法可以通过单个查询获得 Facebook 帖子的总点赞数?
【问题讨论】: