如何在GraphAPI2.0中获取Share_count和like_count

时间:2014-07-11 02:45:27

标签: facebook facebook-graph-api facebook-fql

从FB获取通知,他们将在2.0之后的版本中删除FQL,预计将在2016年。

目前我的应用使用FQL来获取like_count和share_count。我希望有人可以与我分享如何在GraphAPI2.0中实现这一点,因为在GraphAPI中,我只能检索总数。

https://api.facebook.com/method/fql.query?query=SELECT%20url,%20share_count,%20like_count,%20comment_count,%20total_count,%20click_count%20FROM%20link_stat%20where%20url=%27http://www.google.com%27

<fql_query_response list="true"><link_stat>
<url>http://www.google.com</url>
<share_count>5860640</share_count>
<like_count>1446662</like_count>
<comment_count>1775201</comment_count>
<total_count>9082503</total_count>
<click_count>265614</click_count>
</link_stat></fql_query_response>

http://graph.facebook.com/?id=http://www.google.com

{
   "id": "http://www.google.com",
   "shares": 9082503
}

1 个答案:

答案 0 :(得分:1)

使用FQL的最新方法是

https://graph.facebook.com/fql?q=SELECT%20url,%20share_count,%20like_count,%20comment_count,%20total_count,%20click_count%20FROM%20link_stat%20where%20url=%27http://www.google.com%27

如果您想使用旧的(已弃用且仍在使用)api.facebook.com端点,请尝试

https://api.facebook.com/method/links.getStats?urls=http://www.google.com&format=json

这根本不使用FQL,但你无法确定它的工作时间。它甚至不再在他们的文档中了。从Facebook宣布推出Graph API v2.0的后续版本开始,FQL将持续2年左右,因此我建议继续推荐第一个建议。

Graph API v2.0没有端点IMHO来生成除FQL方法之外的URL共享统计信息。