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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With