Skip to main content

ANOTHER, SIMPLER WAY TO DISPLAY FACEBOOK FAN COUNT AS TEXT

I can now show you a much simpler way to display your Facebook fan count as text on your website. It is alot simpler than the previous way, although it is entirely up to you how you wish to display it.
STEP 1 – FIND OUT YOUR FACEBOOK PAGES 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 – eg: http://www.facebook.com/pages/edit/?id=XXXXXXXXX
STEP 2 – COPY AND PASTE

Copy and paste the code below anywhere within your website where you would like the Fan count to show. Remember to change the “XXXXXXXXXXXX” to your Facebook Pages ID.

<?php
$page_id = "XXXXXXXXXXXX";
$xml = @simplexml_load_file("http://api.facebook.com/restserver.php?method=facebook.fql.query&query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=".$page_id."") or die ("a lot");
$fans = $xml->page->fan_count;
echo $fans;
?>

There you have it, a much simpler way of displaying your fan count!

Comments

Popular posts from this blog

Base64 Encode and Decode String in PHP

function base64url_encode($plainText) { $base64 = base64_encode($plainText); $base64url = strtr($base64, '+/=', '-_,'); return $base64url;  } function base64url_decode($plainText) { $base64url = strtr($plainText, '-_,', '+/='); $base64 = base64_decode($base64url); return $base64; }

Send Mail using mail function in PHP

$to = "admin@user.vn"; $subject = "User.vn"; $body = "Body of your message here you can use HTML too. e.g. <br> <b> Bold </b>"; $headers = "From: Peter"; $headers .= "Reply-To:  info@yoursite.com "; $headers .= "Return-Path: mailto:info@yoursite.com"; $headers .= "X-Mailer:PHP5"; $headers .= 'MIME-Version: 1.0"; $headers .= 'Content-type: text/html; charset=iso-8859-1"; mail($to,$subject,$body,$headers);