How To Display Your Feedburner Count And Twitter Followers Without Chicklets

Posted in Tutorials | On 5th February 2010 | 16 Comments

Feedburner offers a great chicklet which allows you to add your subscriber count to your site, and for Twitter you can use a chicklet to display your followers from a service such as twittercounter.com.

What I’m going to show you today is a method of displaying these counts without actually using a chicklet which will allow you to customise how your stats will be displayed.

We will be using PHP to grab the data you need, then you can style with CSS within your own site, Please backup any files before editing them!

FeedBurner

This following code grabs the data from feedburner using the awareness API, replace “YOUR FEED ADDRESS” with your feedburner feed address, e.g. WebM-ag

<?php
$url = file_get_contents('https://feedburner.google.com/api/awareness/1.0/Get
FeedData?uri=YOUR FEED ADDRESS');
$begin = 'circulation="'; $end = '"';
$page = $url;
$parts = explode($begin,$page);
$page = $parts[1];
$parts = explode($end,$page);
$fbcount = $parts[0];
if($fbcount == '') { $fbcount = '0'; }
echo '<b> '.$fbcount.' </b> Subscribers';
?>

This will echo out the count, e.g. 399  Subscribers.

Twitter

This code uses the Twitter API and grabs its count from a XML feed, replace “USERNAME” with your Twitter username, e.g. webmagz

<?php
$twit = file_get_contents('http://twitter.com/users/show/USERNAME.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'; }
echo '<b> '.$tcount.' </b> Followers';
?>

This will echo out your follower count, e.g. 712  Followers

All Done

That’s pretty much the bare bones code you need to get started, you can of course style it in any way you wish, as it uses PHP your page extension MUST be .php (not .html  etc…) or within Wordpress it will work without altering any page extensions.

Demo

Here is a very basic styled demo which is available to download in a .ZIP file

DEMO | DOWNLOAD

McBonio

McBonio is a full time web designer, blogger and general web lurker. He runs Tropica Web Design, which is a web agency based in Liverpool, UK. You can also catch McBonio at Twitter: @mcbonio

Visit McBonio's website

Related Posts

Like this post? Share it!

16 Comments

  • Shurandy Thode
    February 5, 2010
  • Eko Setiawan
    February 8, 2010
  • Sergej Müller
    February 8, 2010
  • McBonio
    February 8, 2010
  • System Dioxide
    February 10, 2010
  • Laneth Sffarlenn
    February 11, 2010
  • McBonio
    February 11, 2010
  • Laneth Sffarlenn
    February 11, 2010