Facebook 点赞和推文的自定义显示

发布于 2024-11-09 10:35:10 字数 268 浏览 0 评论 0原文

如何复制文章 FB 点赞和推文的自定义显示,如 所示这里

您认为这是对 api 的 javascript 调用来检索数字,还是其他什么?如果 API 调用在每个页面加载时调用,那么它们似乎很快就会达到最大。

基本上,如何在第三方 iframe 之外以您自己的标记检索和显示 FB 和 Twitter 统计信息?

How can I replicate the custom displaying of article FB likes and tweets, as seen here?

Do you think it's a javascript call to the api to retrieve the numbers, or something else? It seems like the API calls would quickly max out if they were calling on each page load.

Basically, how can you retrieve and display FB and Twitter stats in your own markup, outside of third-party iframes?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

土豪我们做朋友吧 2024-11-16 10:35:10

您链接到的网站每次被点击时都会增加一个计数器 - 无论是否被共享。尝试单击它,关闭弹出窗口而不共享,然后刷新页面。请注意计数上升。

Facebook 并不真正允许您自定义他们最新的未弃用的共享/点赞按钮。使用实数做到这一点的一种方法是使用他们的图形 API。调用和返回值可以被缓存和/或从后台进程加载以加速页面加载。您可以使用此 URL 获取 Facebook 分享/点赞计数,无需任何访问令牌,这意味着您不会受到速率限制:
http://graph.facebook.com/?ids=http://espn .com

然而,Twitter 还没有 API 调用来获取分享计数,如其 推文按钮常见问题解答。为此,您最好使用他们的计数按钮并使用 CSS 自定义(请参阅构建您的自己的推文按钮),这是受支持的。

That site you linked to is incrementing a counter every time it gets clicked - whether is gets shared or not. Try clicking it, closing the popup without sharing, and then refresh the page. Notice the count goes up.

Facebook doesn't really allow you to customize their latest non-deprecated share/like button. One way you could do this with real numbers is using their graph api. The calls and the returned values could be cached and/or loaded from a background process to speed up page loads. You can get Facebook share/like count by using this URL, without any access token, meaning you won't be rate limited:
http://graph.facebook.com/?ids=http://espn.com

Twitter, however, doesn't have an api call to get share counts yet, as mentioned in their Tweet Button FAQ. For that, you are better off using their count button and customizing it with CSS (see section Build Your Own Tweet Button), which is supported.

暖风昔人 2024-11-16 10:35:10

这些将返回简单的 JSON 响应,其中包含重新推文和转发属性的计数。对特定 URL 的喜欢:

http://urls.api.twitter.com/1/urls/count.json?url=SOME_URL_HERE
http://graph.facebook.com/SOME_URL_HERE

示例:
Twitter API 调用:

http://urls .api.twitter.com/1/urls/count.json?url=http://stackoverflow.com

:: JSON 响应:

{"count":4712,"url":"http://stackoverflow .com/"}

FACEBOOK 图形调用:

http://graph.facebook.com/http: //stackoverflow.com

:: JSON 响应:

{
“id”:“http://stackoverflow.com”,
“股”:7264,
“评论”:3
}

These will return simple JSON responses with counts for property of re-Tweets & Likes for a specific URL:

http://urls.api.twitter.com/1/urls/count.json?url=SOME_URL_HERE
http://graph.facebook.com/SOME_URL_HERE

Examples:
TWITTER API CALL:

http://urls.api.twitter.com/1/urls/count.json?url=http://stackoverflow.com

:: JSON RESPONSE:

{"count":4712,"url":"http://stackoverflow.com/"}

FACEBOOK GRAPH CALL:

http://graph.facebook.com/http://stackoverflow.com

:: JSON RESPONSE:

{
"id": "http://stackoverflow.com",
"shares": 7264,
"comments": 3
}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文