Determining Facebook Like Count and Twitter Tweet Count for a URL

I recently worked on a web site which let users set up a personalized web page, including a Facebook Like button and a Twitter Tweet button.

We needed to determine how many likes and how many tweets each personalized web page got—without visiting each site and noting the count by hand.

This site had the solution for Facebook likes. Let's say your page, containing like and tweet buttons is at http://the.url.com. Simply type the following at the command line: curl "https://api.facebook.com/method/fql.query?query=select%20%20like_count%20from%20link_stat%20where%20url=%22http://the.url.com%22" You'll get back an XML document containing the like count.

For Twitter, I had to reverse-engineer their button code. Simply type the following at the command line: curl "http://urls.api.twitter.com/1/urls/count.json?url=http://the.url.com" You'll get back a JSON document containing the tweet count.

Technical 2011-02-25 15:49:10 UTC