How To Display The Count Of Your Facebook Fans Page In Plain Text

05.01.11 by Jerome in Tutorials

How To Display The Count Of Your Facebook Fans Page In Plain Text

Today I’m going to show you how to display the number of followers you have on your Facebook fan page, in plain text, in your WordPress blog. You’ll see it’s quite simple and should take you only 15 to 20 minutes to implement.

Step 1

Login to your Facebook account and signup for a developer account to get your API Key.

Click the Set Up New Application link –> Select an application name –> Agree to the Facebook terms and go to the next step.

facebookapp How To Display The Count Of Your Facebook Fans Page In Plain TextStep 2

Copy and paste your API Key and Application Secret code into notepad.

facebookapi How To Display The Count Of Your Facebook Fans Page In Plain Text

Step 3

Go to your Facebook Fan Page and get the ID of your Fan page, simply by editing your page. Get the last digit of your page URL.

http://www.facebook.com/pages/edit/?id=PAGEIDNUMBER

Step 4

Download the Facebook API PHP SDK file and under the scr folder get the file named facebook.php and place it in the root of your website.

Step 5

To finish, place this code below where you want to display it and replace the text in capital letters with your own ID’s:

<?php
        require_once('facebook.php');
	$facebook = new Facebook(array(
	'appId'  => 'ADD YOUR OWN FACEBOOK APPLICATION ID',
	'secret' => 'ADD YOUR OWN SECRET KEY',
	'cookie' => true,
	));
	$result = $facebook->api(array(
	'method' => 'fql.query',
	'query' => 'select fan_count from page where page_id = ADD YOUR OWN FACEBOOK FANPAGE ID;'
	));
	$fb_fans = $result[0]['fan_count'];
?>
<p><?php echo number_format($fb_fans); ?> Facebook Followers</p>

facebookcount How To Display The Count Of Your Facebook Fans Page In Plain Text

Stay in Touch with us on Facebook

No related posts.

, ,

Get More Wordpress Tips & Tricks

Liked this post? subscribe to our email updates or RSS feed!

  • http://ineeddiscipline.com Dean Saliba

    Would you say this is better than showing the normal block with photos of the fans? :)

  • http://www.pimpmywordpress.com PimpMyWordPress

    It’s just another way to display it. Sometimes bloggers like to display the number of followers just next to their RSS button feed.

blog comments powered by Disqus