How to get top 30 most liked urls on my website (FQL) - facebook

I'm upgrading my webshop and it involves doing some changes in my product url's (because of SEO optimizing). Since there doesn't seem to be anyway of migrating likes from one url to another and "tricking" the likes to the old url with 301 redirecting is out of the question, i was trying to get a list of the top 20-30 liked urls so i could then loop the result to find the amount of likes, shares etc.
I have already built a small script that finds the like, share etc count for a certain url, but i am unable to find out what the most liked url's are!
Thanks a bunch!

It's possible, but not easy. You'll need to build an FQL query like this:
SELECT url, normalized_url, share_count, like_count, comment_count, total_count
FROM link_stat
WHERE url IN ("example.com/url1", "example.com/url2", ... "example.com/urln")
ORDER BY like_count DESC

Related

Facebook link_stat Incorrect Unique URL Stat

I'm using this FQL to get the number of likes of every article in my app.
SELECT share_count, like_count, comment_count, total_count FROM link_stat WHERE url="http://www.example.com/some/dir/slug"
However, I've been noticing that the number and the like button doesn't seem to take the slug into factor. So when I'm debugging it in Graph API Explorer, the stat for http://www.example.com/some/dir/slug and http://www.example.com/some/dir is the same.
Is this FB bug?
Thanks
The og:url meta tag has to contain the individual URL for each article - otherwise, if it is the same URL value for all articles, Facebook will count all likes for that very URL.

How to extract all the likes from my Facebook pages and add them to my site?

I have a number of Facebook pages, which I provide with daily content. I also have a website on which I promote my services and now I would like to know if it is possible to make somekind of widget which shows the total amount of likes that all my pages have.
Using Facebook Query Language (FQL) you should be able to do this.
something like
SELECT share_count, like_count, comment_count, click_count
FROM link_stat
WHERE url = '$myURL'
Should work using PHP.
See https://developers.facebook.com/docs/reference/fql/ for more info
This is very easy even without a Facebook app:
$pageinfo = file_get_contents('http://graph.facebook.com/' . $pageid);
You can even just try it in the browser. $pageinfo will have some info about your page, AND the like count. Of course you can also use CURL for this, but file_get_contents is a one-liner.

Facebook sharing data for url

I am working on a project to get shares for different articles of the client. I searched whole internet but did not find any info so as a last resort putting the question here:
Is there a way to check how many shares an article has on facebook by giving just the url of the article? I have seen code on facebook where you can get number of likes for your own article you paste but is there a way to tell lets say if some techcruch article has how many facebook shares?
Here is the reference:
https://developers.facebook.com/docs/reference/fql/link_stat/
Sample query to get number of shares for a Techcrunch article:
SELECT url, normalized_url, share_count, like_count, comment_count,
total_count, commentsbox_count, comments_fbid, click_count FROM
link_stat WHERE
url="http://techcrunch.com/2012/07/25/zipongo-seed-round/"
You can play around with different queries here:
https://developers.facebook.com/tools/explorer
(choose FQL from the menu)

Retrieve Facebook users who like a URL/web page

How can I retrieve the list of Facebook users that have clicked the like button on an external site?
Say I have a like button:
<fb:like href="http://example.com/xyz"></fb:like>
I'd like a list of FB user IDs of people who have liked it.
I've tried OpenGraph:
https://graph.facebook.com/OBJECTID/likes/
(where OBJECTID is the id of the like example.com/xyz)
and FQL
select user_id from like where object_id in (
select id from object_url where url = 'http://example.com/xyz'))
but both return empty results.
I can see from other calls that the likes are counted alright, but I can't get the actual users.
Anyone know what permissions etc. I'd need to retrieve these?
Also see this question for sample code.
The simple answer is 'Its not possible to get individual user ids who liked a page'.
https://graph.facebook.com/cocacola/likes?access_token='xxxxxxxxxxxxxxxxxxxxxxx'
will surely return the data about the likes from the user/page but not the list of users who liked the specific object(in this case coca-cola). But make sure you send a proper access_token with proper permissions.
The FQL like is used to get the likes of any objects like video, note, link, photo, or album. To get liked users count of a page please use either link_stat or page from FQL.
the sample query will be like
SELECT url, normalized_url, share_count, like_count, comment_count, total_count,
commentsbox_count, comments_fbid, click_count FROM link_stat WHERE url="facebook.com"
SELECT name, fan_count FROM page WHERE page_id = 19292868552
For more clear answers on this, please read the answer by Jonathan Dean in How to list facebook users who like a page or interest
or ifaour answer in Querying Users who 'like' my Facebook Page

How to collect a URL's facebook likes

Using https://graph.facebook.com/id/likes?access_token=XXXXXXX works for some urls as does http://graph.facebook.com/?ids=url but some urls from locations like washingtonpost.com and techcrunch.com don't have the 'likes' data but it must be available because itstrending.com has these sites listed, with accurate likes counts.
Thanks
You can do this through FQL:
SELECT like_count FROM link_stat WHERE url="http://www.washingtonpost.com"
returns 287.
After digging around some more, I found this: http://developers.facebook.com/docs/reference/rest/links.getStats
Which gives you shares, likes and comments on a url.