使用Graph API代替FQL for Facebook

时间:2013-12-17 06:39:37

标签: facebook facebook-graph-api

我一直在谷歌搜索和堆栈拖钓这样的东西,但似乎无法找到正确的公式,所以我想我会问....

我想要做的是使用Graph API而不是FQL - 我们的应用程序已经运行了php / graph api调用,希望将它们保存在一起。

这是FQL:

SELECT url, 
normalized_url, share_count, like_count, comment_count, 
total_count,commentsbox_count, comments_fbid, 
click_count FROM link_stat WHERE url='http://www.google.com'

尝试了一堆不同的东西,似乎无法翻译它 - 我将假设Link_stat不存在于图形api中,因为它上面没有文档。

想想是否有人可能已经完成它。

我喜欢的样本

https://graph.facebook.com/XXXXX/?ids=http:google.com ( somethin like that )

1 个答案:

答案 0 :(得分:3)

我认为从图表api中获取计数是不可能的,你应该使用FQL link_stat表。不推荐使用FQL。

您可以尝试使用,

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

它会返回结果,

{
   "id": "http://www.google.com",
   "shares": 7991103,
   "comments": 807
}

编辑

https://developers.facebook.com/docs/reference/fql/

2016年8月17日,FQL将不再可用,无法查询。要迁移您的应用,请使用API​​升级工具查看您可以进行的图谱API调用。


https://graph.facebook.com/fql?q=SELECT%20url,%20normalized_url,%20share_count,%20like_count,%20comment_count,%20total_count,commentsbox_count,%20comments_fbid,%20click_count%20FROM%20link_stat%20WHERE%20url='http://www.google.com'

这会回来,

{
   "data": [
      {
         "url": "http://www.google.com",
         "normalized_url": "http://www.google.com/",
         "share_count": 4989540,
         "like_count": 1317162,
         "comment_count": 1684401,
         "total_count": 7991103,
         "commentsbox_count": 807,
         "comments_fbid": 396269740024,
         "click_count": 265614
      }
   ]
}

目前已弃用了相同的REST API方法。

http://api.facebook.com/restserver.php?method=links.getStats&urls=http://www.google.com

请注意:Facebook正在弃用REST API https://developers.facebook.com/blog/post/616/最好选择Graph API / FQL方法。

参考链接:Retrieving facebook share count via api