获取Facebook“喜欢”计算我的域上的每个页面 [英] Get Facebook "Like" count for every page on my domain

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

问题描述

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


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


然而,一次获取我网站上每个页面的计数并不真正可行。除了大量的页面之外,还会不断地创建新的页面(新的用户个人资料,新的博客和博客文章等),这将使得我的站点的完整统计信息变得复杂,并涉及到调用Facebook的API数千次。



有没有办法得到一个请求中每个页面每页多少次喜欢?或者只是前10名最喜欢的页面,或类似的东西?

解决方案

其实我会这样做: p>

  $ 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)

这样就可以将所有的数据作为唯一标识符,而不必打破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天全站免登陆