获取 Facebook 的“赞"计算我域中的每一页 [英] Get Facebook "Like" count for every page on my domain

查看:24
本文介绍了获取 Facebook 的“赞"计算我域中的每一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 Facebook 的赞"按钮集成到我网站的许多页面中.我想在列表中显示我网站上最喜欢"的页面,但我不知道如何在一个请求中从 Facebook 获取该数据.到目前为止,我已经能够使用以下 FQL 查询获得单个页面的喜欢"计数:

<块引用>

SELECT share_count、like_count、comment_count、total_countFROM link_statWHERE url="http://www.mysite.com/some-page"

但是,一次获取我网站上每个页面的计数实际上并不可行.除了拥有大量页面之外,还会不断创建新页面(新用户个人资料、新博客和博客文章等),这将使获取我网站的完整统计数据成为一个复杂的过程,并且会涉及调用 Facebook 的 API 数千次.

有没有办法计算我的域中每个页面在一个请求中被喜欢"的次数?或者只是前 10 个最喜欢"的页面,或类似的东西?

解决方案

其实我会这样做:

$arrayOfPages = array('url1', 'url2', 'url3');$listOfPages = implode(',', $arrayOfPages);选择 share_count、like_count、comment_count、total_count、urlFROM link_statWHERE url IN ($listOfPages)

这将为您提供带有 URL 作为唯一标识符的所有数据,而不必违反 Facebook 针对虚假用户的政策.您可以根据网站数据库上的查询动态创建 $arrayOfPages 变量.

I have integrated the Facebook "Like" button into a lot of pages in my site. I want to display the most "Liked" pages on my site in a list, but I can't figure out how to get that data from Facebook in one request. So far, I have been able to get the "Like" count for individual pages using the following FQL query:

SELECT share_count, like_count, comment_count, total_count
FROM link_stat
WHERE url="http://www.mysite.com/some-page"

However, getting the count for each page on my site one at a time is not really feasible. Aside from having a large number of pages, new pages are being created constantly (new user profiles, new blogs and blog articles, etc), which would make getting complete statistics for my site a complicated process and would involve calling Facebook's API thousands of times.

Is there a way to get a count of how many times each page on my domain has been "Liked" in one request? Or just the top 10 most "Liked" pages, or something similar?

解决方案

Actually I would do it this way:

$arrayOfPages = array('url1', 'url2', 'url3');

$listOfPages = implode(',', $arrayOfPages);

SELECT share_count, like_count, comment_count, total_count, url
FROM link_stat
WHERE url IN ($listOfPages)

That would give you all the data with the URL as a unique identifier without having to break Facebook's policy against fake users. You can dynamically create the $arrayOfPages variable from a query on your site's database.

这篇关于获取 Facebook 的“赞"计算我域中的每一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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