tags:

views:

235

answers:

3

I am building a simple website. I am going to put Facebook Like Button on each article page of this website. How can I track how many people Liked this particular article? Does facebook provide an API for that?

Clarification

I am going to write a script that is going to pull the amount of "likes" for each page every hour. This would allow me to build a popularity graph.

A: 

Yes, facebook provides this type of functionality. Have a look at this widget which currently counts the number of likes for each page of your site.

Alternatively, you can use something like this which produces something along the lines of the following: 37,416 people like this. Be the first of your friends.

Oren
I need to retrieve the number of "Likes" using API of some sort. It will be used internally to rate articles by popularity=F(time,likes).
chromice
A: 

HI, Check this page...it has a wizard to help you generate the code for a like button:

http://developers.facebook.com/docs/reference/plugins/like

But basically all you need is this bit of code:

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgoogle.com&amp;amp;layout=standard&amp;amp;show_faces=true&amp;amp;width=450&amp;amp;action=like&amp;amp;colorscheme=light&amp;amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

and where it says http%3A%2F%2Fgoogle.com just replace that with your url...being careful to make sure the special characters (i.e. the question marks, colons, forward slashes) in your url are encoded using hex characters (you can find all the corresponding hex tags here: http://www.obkb.com/dcljr/charstxt.html)....this way if your article pages are dynamic (i.e. generated by a server side script) then you can just spit the url out in to this iframe code above.

Hope this helps.

elduderino
Setting up the Like button is not a problem. I just cannot find a non-hacky way to retrieve the amount of Likes directly through Facebook API.
chromice
+1  A: 

You will need to run FQL on link_stat table providing url of your article and retrieving like_count field. You can run FQL using FB.Data.query() from JS SDK.

serg
Thank you. I have somehow overlooked FQL.
chromice

related questions