如何使用图形 API 获取分享计数
我可以使用 PHP SDK 和已弃用的 Rest API 获取 URL 的共享计数,但没有找到使用图形 API 获取 URL 的共享计数的方法。
有什么办法可以查到吗?
I can get the share count of an URL using PHP SDK and using the deprecated rest API, but didn't find a way to get the share counts of an URL using graph API.
Is there any way to find out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
以下是获取统计数据的 API 链接列表:
编辑:
删除了 Twitter 端点,因为该端点已被弃用。
编辑:
Facebook REST API 已弃用
Here's a list of API links to get your stats:
Edit:
Removed the Twitter endpoint, since that one has been deprecated.
Edit:
Facebook REST API is deprecated
更新 - 2015 年 4 月:
如果您想获取“赞”按钮中可用的计数,则应使用
og_object
engagement 字段> 对象,如下所示:结果:
可以使用 Graph API,只需使用:
类似的内容:
将返回:
更新: 而上面将回答如何获取共享数数。此数字不等于您在点赞按钮上看到的数字,因为该数字是以下各项的总和:
因此,可以通过
fql
端使用 Graph API 获取“Like”按钮编号-point(link_stat
表):total_count 是“赞”按钮中显示的数字。
UPDATE - April '15:
If you want to get the count that is available in the Like button, you should use the
engagement
field in theog_object
object, like so:Result:
It's possible with the Graph API, simply use:
something like:
Would return:
UPDATE: while the above would answer how to get the share count. This number is not equal to the one you see on the Like Button, since that number is the sum of:
So getting the Like Button number is possible with the Graph API through the
fql
end-point (thelink_stat
table):total_count
is the number that shows in the Like Button.您不应该使用图形 API。如果您致电:
或
两者都会返回:
但是显示的数字是以下内容的总和:
所以你必须使用 FQL。
看看这个答案:如何从文章中获取 Facebook 点赞数、分享数、评论数
You should not use graph api. If you either call:
or
both will return:
But the number shown is the sum of:
So you must use FQL.
Look at this answer: How to fetch facebook likes, share, comments count from an article
2016 年 8 月 7 日之后,您仍然可以像这样拨打电话:
但响应格式将会有所不同: 不会
,而是会
所以您必须像这样处理响应:
After August 7, 2016 you can still make your call like this:
but the response format is going to be different: it won't be
but instead it will be
So you will have to process the response like this:
我发现有用并且在上面的一个链接上发现的是这个 FQL 查询,您可以通过查看 link_stat 表来询问一个链接的喜欢、总数、分享和点击计数,
它将输出如下内容:
What I found useful and I found on one link above is this FQL query where you ask for likes, total, share and click count of one link by looking at the link_stat table
That will output something like this:
查看此要点。它包含如何获取以下服务的共享计数的片段:
Check out this gist. It has snippets for how to get the sharing count for the following services:
facebook like 按钮做了两件 API 没有做的事情。当您比较两者时,这可能会造成混乱。
如果您在“赞”按钮中使用的网址有重定向,该按钮实际上会显示重定向网址的计数与您正在使用的网址的计数。
如果页面有 og:url 属性,点赞按钮将显示该 url 的点赞,而不是浏览器中的 url。
希望这对某人有帮助
The facebook like button does two things that the API does not do. This might create confusion when you compare the two.
If the URL you use in your like button has a redirect the button will actually show the count of the redirect URL versus the count of the URL you are using.
If the page has a og:url property the like button will show the likes of that url instead of the url in the browser.
Hope this helps someone
只需输入
https://graph.facebook.com/?fields=share&id=https://www.example.com
并将 example 替换为您要查找的网址或页面。谷歌的例子:
https://graph.facebook.com/? fields=share&id=https://www.google.com
Simply type in
https://graph.facebook.com/?fields=share&id=https://www.example.com
and replace example with your url or page you are looking for.Example of Google:
https://graph.facebook.com/?fields=share&id=https://www.google.com
当我使用FQL时我发现了问题(但它仍然是问题)
文档显示,显示的数字是以下各项的总和:
包括复制/粘贴链接回 Facebook)
Facebook 上关于此
包含此 URL 作为附件的邮件。
但在我的网站上显示的数字是这 4 个计数的总和 + 股数(再次)
when i used FQL I found the problem (but it is still problem)
the documentation says that the number shown is the sum of:
includes copy/pasting a link back to Facebook)
comments on stories on Facebook about this URL
messages containing this URL as an attachment.
but on my website the shown number is sum of these 4 counts + number of shares (again)
使用 FQL 您可以这样做:
Using FQL you could do that:
有一个 ruby gem - SocialShares
目前它支持以下社交网络:
用法:
There is a ruby gem for it - SocialShares
Currently it supports following social networks:
Usage:
您可以使用https://graph.facebook.com/v3.0/{ Place_your_Page_ID here}/feed?fields=id,shares,share_count&access_token={Place_your_access_token_here} 以获取分享数。
You can use the https://graph.facebook.com/v3.0/{Place_your_Page_ID here}/feed?fields=id,shares,share_count&access_token={Place_your_access_token_here} to get the shares count.