我使用FacebookAPI来获取给定URL的类似/共享计数。奇怪的是,返回结果似乎不一致。例如,此页面返回结果:
https://api.facebook.com/method/fql.query?query=select%20total_count,like_count,comment_count,share_count,click_count%20from%20link_stat%20where%20url='http://www.groupon.com/deals/seattlehelitourscom-by-classic-helicopter-corp'&format=json
然而,这一条没有:
https://api.facebook.com/method/fql.query?query=select%20total_count,like_count,comment_count,share_count,click_count%20from%20link_stat%20where%20url='http://www.livingsocial.com/deals/278194-sunset-kayaking-hot-chowder'&format=json
第二个页面显然有一个共享计数,当我检查页面的HTML时,用于共享的URL就是我放在上面API请求中的URL。然而,API不响应任何数量的喜欢或共享的计数信息。
对于为什么API可能会响应某些URL而不是其他URL,有什么线索吗?
发布于 2018-04-18 15:06:52
从版本2.9开始,你可以创建图形API调用,其中ID是网址并选择'约会'字段,下面是图形浏览器中示例的链接。
发布于 2018-04-18 16:13:43
下面是一个非弃用的方式来获得给定的URL和共享计数(不需要访问令牌):
结果:
{
"og_object": {
"likes": {
"data": [
],
"summary": {
"total_count": 83
}
},
"id": "10151023731873397"
},
"share": {
"comment_count": 0,
"share_count": 2915
},
"id": "https://www.stackoverflow.com"
}
JQuery示例:
$.get('https://graph.facebook.com/'
+ '?fields=og_object{likes.summary(total_count).limit(0)},share&id='
+ url-goes-here,
function (data) {
if (data) {
var like_count = data.og_object.likes.summary.total_count;
var share_count = data.share.share_count;
}
});
参考:
https://developers.facebook.com/docs/graph-api/reference/url
https://stackoverflow.com/questions/-100008167
复制相似问题