How To Display Facebook Fan Count In Text
Page ID
Step 2 – Get
Page ID
Step 2 – Get
Adding a Facebook Like Button on your website or blog is perhaps one of the easiest and most effective way to get more fans and earn more likes. If you have hundreds, thousand or perhaps tens of thousand of fans, it might be a good idea to publish a fan count. Fan count displays in numeric text total fans your Facebook page has, or rather, how many have liked your page.
The technique is simple and very similar to displaying Google feedcount in text. The only difference is – we will be using Facebook’s API. In this post, we want to show you how it can be done so you can add them into yourWordPress blog or PHP powered website. Load up your favorite code editor, here we go.
Step 1 – Get API Key, Application Secret & Page ID
These are the three mandatory information you’ll need to get things started.
API Key and Application Secret
- Sign in to your Facebook and click on Developer‘s link on the site bar. (If you don’t have a Developer’s account, you will have to sign up for one first)
- Click "Set Up New Application". Enter any application name, agree to the Facebook terms and click"Create Application". Note: We are not going to create a real application, but we’ll need to go through these processes to get a API Key and Application Secret.
- 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
. Download it, and place it in the root of your folder. Learn more about Facebook PHP SDK.Step 3 – Display Fancount
To show off your fancount, place the following code in your php file,
- <?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
.
To display the fancount, insert this following code anywhere in the page:
- <?php echo $fb_fans; ?>
That’s all. Style your fancount and make it attractive. See a working example on Psdeluxe‘s top right corner.
How to Use Facebook 20Tips
If you surf Facebook on daily basis or occasionally, chances are you’re already familiar with regular stuffs like add/delete friends, update statuses, walls and profile, add and explore pages & applications, etc, but there’s more..
This week we want to cover some interesting things you can do on (or with) Facebook; inclusive of tricks that are not documented or unknown to many, as well as tips to stay connected better with your friends. Without further ado, here’s 20 Facebook Tips/Tricks You Might Not Know. If you have interesting tips/tricks related to Facebook, please feel free to share in the comment box below.
How To Place Facebook Chat On Firefox Sidebar
If you are using Firefox, you can place the Facebook Chat at the sidebar.How To Download Facebook Photo Albums
FacePAD: Facebook Photo Album Downloader allows you to download your friends’ facebook albums, Events albums, and Group Albums, en masse, with the click of a button.How To Share Flickr Photos To Facebook
Flickr2Facebook is an unofficial Flickr to Facebook uploader(bookmarklet) which allows you upload photos to Facebook from Flickr.How To Update Facebook Without Using Facebook- hellotxt and Ping.fm both introduced features that let Facebook administrators update Facebook Pages.
How To Schedule Facebook Messages
Sendible lets you schedule Facebook messages ahead of time so you can send messages to your friends, customers or colleagues in the future.How To "Friend" Someone On Facebook & Hide It From Your Status Updates
A short tutorial on Makeuseof to guide you how to hide Facebook status updates and keep that fact confined to your closer friends.How To Create A Photo Collage Using Pictures Of Your Facebook Friends
Click on Friends tab. Proceed to More tab. From "Choose an option" dropdown, choose any of the dashes "—" . Your Facebook friends collage is right on your computer screen.How To Know When Facebook Friends Secretly Delete Or Block You
This service has been discontinued. X-Friends is a unique tool for tracking friends that disappear from Facebook.How To Display Selected Pictures Only On Your Facebook Profile Page
A little-known feature in Facebook that lets you decide who shows up in that Friends box. Click that "edit" pencil in your Friends box and type the names of your best friends in the box that says "Always show these friends"How To Remove Facebook Advertisements
This Greasemonkey script – Facebook: Cleaner removes many of the annoying ads and updates that unavoidably appear on your Facebook pages.How To Syncs Photos Of Facebook Friends With Contacts In Microsoft Outlook
OutSync is a free Windows application that syncs photos of your Facebook friends with matching contacts in Microsoft Outlook. It allows you to select which contacts are updated. So you can update all contacts at once or just a few at a time.How To Display Facebook Statuses On WordPress Blog
The following method make use of Facebook status feed and WordPress RSS widget to display Facebook Statuses on WordPress blog.. It will also work for self-host WordPress blogs.How To Post Your Blog Posts To Your Facebook Wall Automatically
Wordbook allows you to cross-post your blog posts to your Facebook Wall. Your Facebook “Boxes” tab will show your most recent blog posts.How To Access Facebook Chat On Desktop
How To Create Quiz On Facebook Easily
LOLapps provides quiz creator that can be employed to conjure up these popular personality quizzes that are so widespread in Facebook.How To Hide Your Online Status On Facebook Chat From Select Contacts
Facebook has integrated friends list with Chat and you can also choose which of these list members get to see you online.How To Get Facebook Updates On Email
NutshellMail consolidates your Facebook accounts through the inbox you use the most.How To Update Facebook Status From Firefox
FireStatus is a status update utility for multiple social networks, including FaceBook.How To Get Facebook On Your Desktop
Seesmic Desktop, Facebooker, Xobni, Facebook Sidebar Gadget, Scrapboy and Facebook AIR application are desktop applications that allows you interact with your stream just as you would on Facebook, but without the browser.How To Delete, Cancel And Terminate Facebook Account And Profile
A simple guide to terminate, delete or cancel Facebook account, together with the Facebook profile easily.
How To Display Facebook Fan Count In Text
Adding a Facebook Like Button on your website or blog is perhaps one of the easiest and most effective way to get more fans and earn more likes. If you have hundreds, thousand or perhaps tens of thousand of fans, it might be a good idea to publish a fan count. Fan count displays in numeric text total fans your Facebook page has, or rather, how many have liked your page.
The technique is simple and very similar to displaying Google feedcount in text. The only difference is – we will be using Facebook’s API. In this post, we want to show you how it can be done so you can add them into yourWordPress blog or PHP powered website. Load up your favorite code editor, here we go.
Step 1 – Get API Key, Application Secret & Page ID
These are the three mandatory information you’ll need to get things started.
API Key and Application Secret
- Sign in to your Facebook and click on Developer‘s link on the site bar. (If you don’t have a Developer’s account, you will have to sign up for one first)
- Click "Set Up New Application". Enter any application name, agree to the Facebook terms and click"Create Application". Note: We are not going to create a real application, but we’ll need to go through these processes to get a API Key and Application Secret.
- 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
. Download it, and place it in the root of your folder. Learn more about Facebook PHP SDK.Step 3 – Display Fancount
To show off your fancount, place the following code in your php file,
- <?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
.
To display the fancount, insert this following code anywhere in the page:
- <?php echo $fb_fans; ?>
That’s all. Style your fancount and make it attractive. See a working example on Psdeluxe‘s top right corner.
No comments:
Post a Comment