2012-02-27 31 views
20

我发现图api中存在一些不一致,并且想知道是否有人能够解决这些问题。获取特定网址的Facebook *份数*

https://graph.facebook.com/?id=http://www.imdb.com/title/tt0117500/输出一个“likes”数字以及imdb提供的与其fb:app_id关联的所有打开图形信息。然而, https://graph.facebook.com/?id=http://www.google.com输出“份额”数字,因为谷歌不提供fb:app_id或fb:admins。

我的问题是,我需要为第一URL的“股份”号,因为它与(,喜欢+评论等)

在其like button暴露数量对应有什么办法能够可靠地得到这个任何网址的“共享”号码?

回答

57

该API不再可用。下面的答案不再有效。


我能得到只是一个GET请求API页面的统计数据(比如http://techcrunch.com)。只需将此GET请求http://api.facebook.com/restserver.php?method=links.getStats&urls=[YOUR_URL]并获取统计信息即可。

http://api.facebook.com/restserver.php?method=links.getStats&urls=http://techcrunch.com/ 回报

<links_getStats_response xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true"> 
    <link_stat> 
     <url>http://techcrunch.com/</url> 
     <normalized_url>http://www.techcrunch.com/</normalized_url> 
     <share_count>6244</share_count> 
     <like_count>1513</like_count> 
     <comment_count>1391</comment_count> 
     <total_count>9148</total_count> 
     <click_count>4007</click_count> 
     <comments_fbid>433841427570</comments_fbid> 
     <commentsbox_count>4</commentsbox_count> 
    </link_stat> 
</links_getStats_response> 

希望这有助于。


此外,

如果您希望响应的JSON,只是追加&format=json请求URL - (!从注释由于德克斯特)德克斯特

+10

如果你想把这个响应作为JSON,只需追加'&format = json'来请求URL – Dexter 2014-04-09 12:19:46

+6

这个API不再可用。 – 2016-12-06 20:24:30

+0

不再有效。 – lcm 2017-06-16 20:22:23

6

您需要使用Facebook的FQL与表link_stat。使用类似于此

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.imdb.com/title/tt0117500/" 

某事,这是该查询的结果(XML格式,当然你也可以把它在JSON)

<?xml version="1.0" encoding="UTF-8"?> 
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true"> 
    <link_stat> 
    <url>http://www.imdb.com/title/tt0117500/</url> 
    <normalized_url>http://www.imdb.com/title/tt0117500/</normalized_url> 
    <share_count>6233</share_count> 
    <like_count>9500</like_count> 
    <comment_count>2179</comment_count> 
    <total_count>17912</total_count> 
    <commentsbox_count>6</commentsbox_count> 
    <comments_fbid>380728101301</comments_fbid> 
    <click_count>164</click_count> 
    </link_stat> 
</fql_query_response> 

的TOTAL_COUNT(17912)是你的号码寻找。

+0

“截至8 2016年8月,FQL将不再可用并且无法查询“。 - https://developers.facebook.com/docs/technical-guides/fql/ – 2016-12-06 20:20:03