获取给定网址的Facebook /共享计数 [英] Getting the Facebook like/share count for a given URL

查看:132
本文介绍了获取给定网址的Facebook /共享计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Facebook API获取给定网址的类似/共享数。奇怪的是,在返回结果中似乎相当不一致。例如,此页面返回结果:

I'm using the Facebook API to get the like/share count for given URLs. The strange thing is that it seems to be quite inconsistent in returning results. For example, this page returns results:


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
Whereas, this one does not:

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

第二页显然有一个共享数,当我检查页面中,正在用于分享的网址是上述API请求中的URL。但是,API没有针对任何数量的喜好或共享的任何计数信息进行响应。

The second page clearly has a share count on it, and when I inspect the HTML of the page, the URL which is being used to share is the one I've placed into the API request above. However, the API does not respond with any count information for either number of likes or shares.

任何关于为什么API可能会响应一些URL而不是其他URL的线索?

Any clues on why the API might be responding for some URLs but not for others?

推荐答案

更新: 此解决方案已不再有效。自2006年8月7日起,FQL已被弃用。

https://api.facebook.com/method/fql.query?query=select%20%20like_count%20from%20link_stat%20where%20url=%22http://www.techlila.com%22

另外 http://api.facebook.com/restserver.php?method=links.getStats&urls=http://www.techlila.com 将向您显示所有数据,如共享计数 ,喜欢计数和评论计数以及所有这些的总计。

Also http://api.facebook.com/restserver.php?method=links.getStats&urls=http://www.techlila.com will show you all the data like 'Share Count', 'Like Count' and 'Comment Count' and total of all these.

更改URL(即 http://www.techlila.com )根据您的需要。

Change the URL (i.e. http://www.techlila.com) as per your need.

这是正确的URL,获得正确的结果。

This is the correct URL, I'm getting right results.

编辑( May 2017):从v2.9开始,您可以创建一个图形API调用,其中ID是URL,并选择参与字段,以下是与图形资源管理器的示例的链接。

EDIT (May 2017): as of v2.9 you can make a graph API call where ID is the URL and select the 'engagement' field, below is a link with the example from the graph explorer.

https://developers.facebook.com/tools/explorer/?method=GET&path=%3Fid%3Dhttp%3A%2F%2Fcomunidade.edp.pt%26fields%3Dengagement&version=v2.9

这篇关于获取给定网址的Facebook /共享计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆