Responsive SMF Themes. We're currently working on brand spankin' new Responsive SMF themes for SMF 2.1

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

Mick in Tutorials
Jun 21, 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
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
//End Feedburner Counter

//Begin Facebook Counter
        require_once('facebook.php');
   $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">
<td>
<font size="1" color="#d97b33">Facebook Fans</font><br /><font color="#346" size="2"><strong><center>'.$fb_fans.'</center></strong></font>
</td>
<td>
<font size="1" color="#d97b33">Twitter Followers</font><br /><font color="#346" size="2"><strong><center>'.$tcount.'</center></strong></font>
</td>
<td>
<font size="1" color="#d97b33">RSS Subscribers</font><br /><font color="#346" size="2"><strong><center>'.$fb.'</center></strong></font>
</td>
</tr>
</table>';

   //End of Social Text Counter v.1



Mick

Mick G

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

Website: https://www.idesignsmf.com/

    


2 Comments

BaghdadGhost
Jul 03, 2012
thanks a lot
1

Mick
Jul 06, 2012
Pretty easy!  ;)
2



Connect with us:


Improve SMF

If you wish to contribute to the development of SMF you can contribute to the coding discussions taking place on Github. You are also welcome to suggest features which you would like to see added to the software in the Feature Requests board.

  Receive our monthly newsletter right in your inbox.


Advertisement  




 Tutorials
In this section you will find in-depth how-to's involving common SMF development and design techniques.



go up