How to collect a URL's facebook likes - facebook

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.

Related

facebook api - get likes and number of comments made for a specific period

I am pretty new to Facebook api's and would like to know if it's possible to fetch the number of likes and also the number of comments for any specific page for a given period of time via the api?
Thanks in advance.
you can use FQL:
e.g.
select comment_count, share_count, like_count from link_stat where url = "http://techcrunch.com/2011/04/12/facebook-comments-now-on-over-50k-sites-get-more-social-with-latest-upgrade/"
you can use this api explorer as your reference:
https://developers.facebook.com/tools/explorer/?fql=select+comment_count%2C+share_count%2C+like_count+from+link_stat+where+url+%3D+%22http%3A%2F%2Ftechcrunch.com%2F2011%2F04%2F12%2Ffacebook-comments-now-on-over-50k-sites-get-more-social-with-latest-upgrade%2F%22

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

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

Facebook get like count for search query

I'm using https://graph.facebook.com/search?q=watermelon&type=post to retrieve posts with query watermelon. Is it possible to also get the like count for the posts I retrieve?
The likes element is returned for search result entries that have been liked. Not all posts have been liked or the users permissions don't allow viewing of likes. Here is a screenshot from the graph explorer though for your query which has some likes information:
The Facebook FQL does not have the feature of count, but you could always count the number of objects in the array with whatever language you are using.

Facebook count likes generated for an external site

We have references to other companies on our website and provide the option for people to 'like' them. After a quick skim of the Facebook documentation, I can't work out how to calculate the number of likes our website generates for others so we can measure our effectiveness. Is this possible?
Thanks
The easiest way to get this from the graph api for example https://graph.facebook.com/http://www.google.com there you can find the total number of likes and comments
You can subscribe to "edge.create" and count user likes of any like button on your site.
http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
There is another source (website or something) that have a like button with the same url? if not, you can query link_stat table using FQL to know the number of likes of a url. if yes, I think that the only option is to store the likes count in your website code, in a database or something.

Number of likes for a photo or album thru the API

Is it possible to get the number of likes for a photo or album using facebook's API?
This is a link to the open graph for an album
http://graph.facebook.com/99394368305
but it doesn't have the number of likes.
on facebook, you can see it has 2475+ likes
http://www.facebook.com/media/set/?set=a.99394368305.88399.40796308305
thanks
To get the likes for a photo is easy, as you can see in the API Reference:
http://developers.facebook.com/tools/explorer/?method=GET&path=20531316728
For an album you can use the likes connection to get all members who liked that album. So, in your case:
http://graph.facebook.com/99394368305/likes
Notice that that won't return the count. You have to manually go through the results and count the likes. So you should definitely cache the results!
Try to use something like this as the URL to fetch what you need:
https://graph.facebook.com/albumID/photos?fields=id,likes.summary(true),comments.summary(true)&access_token=XXXXXX
Here is a post that explains how in detail.