WordPress get Facebook Likes

To receive Facebook likes for you Blogpost your can query  Facebook via Fql. If you have hunderts of posts urls and want to cache the Like and shares you can build  the query in your post loop WordPress theme .  To prevent slowing down too much you should cache the result for some time in your database for example in a Custom Fields  . Like in these Blog we remove the facebook like counter on the front page and show a Interaction Bubble what is a summ of comments and Facebook Interaction. Additional you can add and store retweets by blogpost too that will give the vistor a good reverence what is the most aktive content on your page.


Example Query :

SELECT url, normalized_url, share_count, like_count, total_count FROM link_stat WHERE url in ("facebook.com", "google.com") ORDER BY total_count DESC
Test your query in the Test console : https://developers.facebook.com/docs/reference/rest/fql.query/
How to integrate Reffernce with example Script : https://developers.facebook.com/docs/reference/fql/


Sample XML Like request for a web Url

$xml = simplexml_load_file("http://api.facebook.com/restserver.php?method=links.getStats&urls=$url");




The FQL returns a array of following data

share_count  like_count   comment_count   total_count  click_count  comments_fbid   commentsbox_count

Feature would be to build that in a function or plugin . Once stored its simple to sort  and show on custom pages or widgets by likes or any other social Graph  data you like on your WP Page .

The Interesting part beside the technical stats  numbers is now you can build pages and content that reflect on the Social Interaction on the post . Something like a Fangate based on Numbers of Likes , Award returning visitors with gifts or special Event invitation , ViP Guest List ect .



Notify of
Inline Feedbacks
View all comments