Join The Community

Premium WordPress Themes

Search

Saturday, July 2, 2011

How To Fetch Facebook Page Likes Counts In Plain Text

Facebook is the best place to spread your blog news and site products. Almost all top blogs use facebook to spread their articles all over their facebook page fans. Getting Facebook Fan Page likes in text plain is so simple and its only a 5 line code. Just what you need is a PHP version above 5.2.0 and your fan page ID or fan page name (Vanity URL).

And also do not forget to place your facebook page ID or facebook page name in the place of Page ID/Page Vanity URL. This counts your facebook likes according to the data stored in the facebook protocols.

Paste this function in your theme functions.php file and save the file.
function bfan() {
$pageID = 'Page ID/Page Vanity URL';
$info = json_decode(file_get_contents('http://graph.facebook.com/' . $pageID));
echo $info->likes;
}

After saving the file, you can use the function calling code directly to call the function and display Facebook Fan Page likes in plain text. To call the function, you can use this:

<?php bfan(); ?>

0 comments:

Related Posts Plugin for WordPress, Blogger...