5 Ways to Show Your Total Feedburner Subscriber Count

Most websites these days show off their feedburner subscriber count. Some of them just displays the chicklet provided by feedburner whereas others show it in a flashy and cool look. Below is a list of 5 methods to show your total feedburner subscriber count.

Tweak the Default Chicklet

Lets start with the easiest one, directly using the feedburner chicklet. You can’t customize it much apart from changing the following things. Look carefully at the URL provided by feedburner in the chicklet code,

http://feeds.feedburner.com/~fc/AgentWordpress?bg=99CCFF&fg=444444&anim=0? height=”26? width=”88? style=”border:0? alt=””

you’ll notice that the following things can be changed

  • background color, by changing the bg parameter.
  • foreground color, by changing the fg parameter.
  • animation can be turned on or off by toggling the anim parameter.
  • height and width can be changed by changing the respective parameters.
  • style can be similarly changed using the style parameter.

All the above options are not much useful since they can be customized directly from the feedburner administration panel. But one more thing that most people don’t know is that we can change the label on chicklet as well. By default, it shows readers, but by using

&label=yourtext

in the url, the label can be replaced by the custom label. For example, instead of,

chicklet1

you can display,

chicklet2

Just append the url in the source provided by feedburner with &label=fans and then use it in your template file or sidebar text widget.

Using XML Processing

The second method involves XML parsing. The following code retrieves many parameters related to your feed from feedburner in XML format, then it takes out the circulation element from the XML file.

Just use the following code along with appropriate CSS formatting to display your subscription count.

<?php
$xml = simplexml_load_file
("http://api.feedburner.com/awareness/1.0/GetFeedData?uri=yourURI")
or die ("Unable to load XML file!");

$circulation = $xml->feed->entry[‘circulation’];
echo $circulation;
?>

Replace the yourURI with the URI parameter of your feedburner account. Note that its URI and not UID.

Using Curl

The third method uses cURL library. Replace the feedburner-id with the feedburner-id of your feedburner account.

<?php
//get cool feedburner count
$whaturl="http://api.feedburner.com/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’];

//get cool feedburner count
echo $fb;
?>

Using RegEx

This code was released recently by Joost De Valk of Yoast.com. It uses regular expressions to retrieve the circulation element from the XML output received from the feedburner. Don’t forget to replace the feedburner-id with the feedburner-id of your feedburner account.

<?php
$fb = get_option("feedburnersubscribecount");
if ($fb[‘lastcheck’] < ( mktime() – 600 ) ) {
$snoopy = new Snoopy;
$result = $snoopy->fetch("http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id");
if ($result) {
preg_match(‘/circulation="([0-9]+)"/’,$snoopy->results, $matches);
if ($matches[1] != 0)
$fb[‘count’] = $matches[1];
$fb[‘lastcheck’] = mktime();
update_option("feedburnersubscribecount",$fb);
}
}
echo $fb[‘count’];
?>

Note that, if you get an error saying it can’t find the class Snoopy, then add the following line to the above code,

require_once(ABSPATH . ‘wp-includes/class-snoopy.php’);

Use WordPress Plugin

Another, and the most easiest way is to use some wordpress plugin. You can find one such plugin here. Many more such plugins are available at WordPress Plugin Directory

Note that while looking for plugins related to feedburner api, you’ll find many plugin which display the feedburner stats, including subscriber count, only on the dashboard (or admin panel). For example, the following two plugins show the stats on dashboard,

Using these plugins, you can monitor the feedcount, and once it reaches your desired threshold, say 500, you can decide to show the feedcount on the homepage of your site using the above methods.

Leave a Comment