我想在页面上的帖子中获得喜欢:" The Jungle Book"
我可以使用网址获取该页面的内容:
https://graph.facebook.com/" + pageId + "?fields=likes&access_token=" + ACCESS_TOKEN
我看过documentation
并且发现只有在设置标志summary=true
时才会返回该帖子的喜欢(总计数)
响应应该如下所示
{
"likes": <somecount>,
"id": "151505938209071_1507814655911519"
}
我可以在页面上获得喜欢的内容但无法在该页面上的特定帖子中获得喜欢的总数。
任何人都可以帮助我如何设置URL或有任何其他方法来做到这一点。
答案 0 :(得分:0)
根据你所描述的,听起来应该是这样的:
https://graph.facebook.com/" + pageId + "?fields=likes&summary=true&access_token=" + ACCESS_TOKEN
以上是summary=true
和fields=likes
参数之间access_token
的现有网址
但您可能对this answer
感兴趣引用:
无法在文档中找到此信息,但无需多次调用API。您可以在查询Feed或多个帖子时使用摘要。在fields参数中指定它。
https://graph.facebook.com/PAGE_ID/feed?fields=comments.limit(1).summary(true),likes.limit(1).summary(true)
这将返回这样的回复。
{ "data": [ { .... "summary": { "total_count": 56 } ... }, { .... "summary": { "total_count": 88 } ... } ] }
这比为每个对象单独发出请求只是为了得到评论或喜欢的数量要快得多。