Skip to main content

HOW TO DISPLAY FACEBOOK FANS COUNT AS TEXT

Want to show off how many fans your Facebook page has? I will now explain how to do so in just a few steps!
STEP 1 – GET API KEY, APPLICATION SECRET & PAGE ID

API Key and Application Secret

First off, you’ll need to login to Facebook and click the Developer link on the footers site bar. If you don’t already have a Developer Account, you’ll have to sign up for one first.

Secondly, you’ll need to create a new App, click the Apps link in the top nav bar. Then hit + Create New App. We aren’t actually going to create an App, we just need to go through this process to get an API Key and Application Secret.



Thirdly, on the next page you should be able to see your personal API Key and Application Secret. Copy it down somewhere or leave the browser window open.



Page ID

Page ID is the ID of your Facebook Fan Page. If you don’t have a Facebook Fan page, you’ll have to first create one. To get the ID of your Fan page, click edit page, and look for your ID (numbers) at the end of the URL – http://www.facebook.com/pages/edit/?id=XXXXXXXXX
STEP 2 – GET FACEBOOK.PHP

You’ll also need the Facebook API PHP SDK file called Facebook.php. Click here to get thefacebook.php code. Just copy and paste the code into a blank file and save as facebook.php and save it to your root folder of your websites directory.
STEP 3 – DISPLAY THE FAN COUNT

To display the fan count copy and paste the following code anywhere into the php file your count will be displayed on:

<?php
require_once('facebook.php');
$facebook = new Facebook(array(
'appId' => 'app_id',
'secret' => 'secret_key',
'cookie' => true,
));
$result = $facebook->api(array(
'method' => 'fql.query',
'query' => 'select fan_count from page where page_id = page_id;'
));
$fb_fans = $result[0]['fan_count'];
?>

And then you will want to edit the codes to change the following:

Line 4 – Replace app_id with your Facebook Application ID.
Line 5 – Replace secret_key with Secret.
Line 10 – Replace the last page_id with your Facebook Fanpage ID.

Please refer to Step 1 on how to get app_id, secret_key and page_id

Now simply copy and paste the following code where you want the Fan count to display:

<?php echo $fb_fans; ?>

STEP 4 – STYLING

Finally you can style your fan count, here is an example:

HTML

<?php
require_once('facebook.php');
$facebook = new Facebook(array(
'appId' => 'app_id',
'secret' => 'secret_key',
'cookie' => true,
));
$result = $facebook->api(array(
'method' => 'fql.query',
'query' => 'select fan_count from page where page_id = page_id;'
));
$fb_fans = $result[0]['fan_count'];
?>

<p><span class="fb-count"><?php echo $fb_fans; ?></span> Facebook Fans</p>


CSS

p {
color:#fff;
}

span.fb-count {
font-size: 22px;
padding-left: 5px;
color: #1e7c9a;
}

Simple really isn’t it? Again if you come across any problems then please comment and one of us shall assist you.

Comments

Popular posts from this blog

75 Surprisingly Creative Facebook Timeline Covers

Now that you have shifted to “Facebook Timeline” to display you profile in a better way, get creative with it. Facebook timeline gives you a chance to turn you profile exclusive and innovative. Putting up a personal picture as cover, will only make you look outdated. You can try some exciting covers to design your very own Facebook profile in distinguished style. We have scrounged through web to pick 75 amazing Facebook Timeline covers for this list. Unique cover pictures can give your timeline a different-from-the-rest look. You can create your own creative covers picking ideas from these cool pictures listed below. If you like this article, you might be interested in some of our other articles on  Facebook Scripts, Best Facebook Apps, Best Facebook Games, and Facebook Tips You Should Check . Ekkapong Techawongthaworn Be a brand ambassador and flaunt your fanaticism for gadgets and shopping on your cover. Ekkapong Techawongthaworn Gabriel Fort A snapshot of an Apple iPad interface.

30 Free Facebook Timeline Cover Backgrounds

If you really want a good cover for your Facebook Timeline, you have landed on the right page. It’s seen that people have faced problem in finding covers of their choice because of the specific size issue. However, you do not need to look further, as this list presents 30 cool free Facebook Timeline covers for you to sport them on your profile page. The list includes creative, funny, exciting and cool pictures of perfect dimensions to fit your Facebook cover without having you to crop or resize them. Moreover, they are absolutely free to download, so you can instantly put them on your Timeline cover to express numerous moods and inspirations. If you like this article, you might be interested in some of our other articles on  Thumbs Up Symbol,Heart Symbol On Facebook, Facebook Timeline Covers and Facebook Timeline As Used By Brands . Love Calculator What all it takes to result in love? A pretty woman and drinks. Love Calculator This Guy Rocks Let your cover boast about you and tell your

PHP File Upload

With PHP, it is possible to upload files to the server. Create an Upload-File Form To allow users to upload files from a form can be very useful. Look at the following HTML form for uploading files: <html> <body> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> Notice the following about the HTML form above: The enctype attribute of the <form> tag specifies which content-type to use when submitting the form. "multipart/form-data" is used when a form requires binary data, like the contents of a file, to be uploaded The type="file" attribute of the <input> tag specifies that the input sho