Get our posts emailed to you with our monthly newsletter, subscribe here.

Following on from my tutorial that shows you how to display your latest Tweet on your website, I will now show you how to show of your Feedburner subscribers count in plain text on your website. Feedburner does already give you the option to display your count on your site using their ‘chicklets’ but these are widget like icons that aren’t particularly customizable and for my site, they did not look right!

The advantage of been able to display your subscibers count in plain text is that you can customize it endlessly! You can even use jQuery to add the hover over ‘show count’ effect you often see on RSS icons. Needless to say, this way is much better then the Feedburner chicklets.

Right, first thing you need to do is use a bit of code to pull the count, and second you need to display it on your site. This first bit of code needs to be somewere near the top of your page, like your header…

[php] <?php
$temp="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=FEEDBURNERID";

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $temp);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data);

$feedcount = $xml->feed->entry[‘circulation’];
?>
[/php]

Don’t forget to change where it says FEEDBURNERID to the Feedburner ID relivant to your account. Now that you have the feed count in the variable $feedcount you are free to display it on your site, for example…

[php] There are currently <?php echo $feedcount; ?> subscribers.
[/php]

The script requires PHP5, so if you are encountering any errors, then it is likely your are running an older version of PHP, otherwise, you may have used an incorrect Feedburner ID. Also please note that this script is for Google Feedburner accounts. Google acquired Feedburner a while back so if you haven’t converted your Feedburner account into a Google one then you will need to do so before you use this script.

Posted by Stu Greenham

Stu Greenham is a Web Designer / Developer who lives in Hull (North East England) and works for the web agency.

2 Comments

  1. Same here. I get the same error. Can’t figure out what goes wrong. This code was working just fine on my old WordPress site. I have just changed the design and upgraded to WordPress 2.9.

  2. Hi

    I tried using the above code to get the number of rss subscribers for a blog. But I am getting an error
    ‘Fatal error: Uncaught exception ‘Exception’ with message ‘String could not be parsed as XML’ in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\manju\ab\getrsssubscribers.php:10 Stack trace: #0 C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\manju\ab\getrsssubscribers.php(10): SimpleXMLElement->__construct(”) #1 {main} thrown in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\manju\ab\getrsssubscribers.php on line 10′

Comments are closed.