[TUT] How To Display Facebook, Twitter & Feedburner Subscriber Count In Text

in Tutorials on 21 Jun 2012

I believe you?ve seen websites and blogs that uses the text-based Feedburner subscriber count instead of the chicklet. I hope you are not getting the idea the these guys update their feed count manually. Instead, it can be done easily with scripts, and the reason why you want to do is ? it gives you total flexibility in terms of design, styling and display.

Create a PHP block using your favorite portal and insert this code.  Make sure you replace all ID's and modify the code to suit your needs. ie, color, background, size.

Have fun ;)

//Social Text Counter v.1 by idesign360.com

//Begin Twitter Counter
$twit = file_get_contents('http://twitter.com/users/show/TWITTER ID.xml');
$begin = '<followers_count>'; $end = '</followers_count>';
$page = $twit;
$parts = explode($begin,$page);
$page = $parts[1];
$parts = explode($end,$page);
$tcount = $parts[0];
if($tcount == '') { $tcount = '0'; }
//End Twitter Counter

//Begin Feedburner Counter
//get cool feedburner count
$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=FEEDBURNER ID";

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
//End Feedburner Counter

//Begin Facebook Counter
   $facebook = new Facebook(array(
   'appId'  => 'FACEBOOK APP ID',
   'secret' => 'FACEBOOK SECRET ID',
   'cookie' => true,
   $result = $facebook->api(array(
   'method' => 'fql.query',
   'query' => 'select fan_count from page where page_id =FACEBOOK FAN PAGE ID #;'
   $fb_fans = $result[0]['fan_count'];
//End Facebook Counter

echo '
<table width="275px" height="40px" bordercolor="#dcdcdc" bgcolor="#f7f7f7" cellpadding="2" cellspacing="5">
<tr valign="top">
<font size="1" color="#d97b33">Facebook Fans</font><br /><font color="#346" size="2"><strong><center>'.$fb_fans.'</center></strong></font>
<font size="1" color="#d97b33">Twitter Followers</font><br /><font color="#346" size="2"><strong><center>'.$tcount.'</center></strong></font>
<font size="1" color="#d97b33">RSS Subscribers</font><br /><font color="#346" size="2"><strong><center>'.$fb.'</center></strong></font>

   //End of Social Text Counter v.1

PixelfyStudio Team
Mick is an American theme designer for Simple Machines Forum software currently living in South Florida, USA. He runs PixelfyStudio.com and started tinkering with SMF in 2006 where he created several SMF forums of his own before he founded PixelfyStudio in 2009 to which he is dedicated full time.

PixelfyStudio.com | SimpleMachines.org


Tutorials. We have a great selection of tutorials to help you make the most of your theme.