Display Feedburner Subscriber Count

I used to have the number of subscribers on my blog displayed as text on the sidebar of this blog for sometime, but when my feeds got migrated to feedburner.google.com which was incentivized to me with their Adsense for RSS, my subscriber count just stopped updating and it was showing me errors.

The new URL with feedproxy disrupted their awareness API which was used for calling the subscriber numbers. Yoast yesterday found a fix/hack for this problem and it really works like a charm for my blog now. For an example, see the top sidebar, it says “Join my 1070 Subscribers” now. The code for showing this on your wordpress blog is:

$fb = get_option("feedburnersubscribecount");
if ($fb['lastcheck'] < ( mktime() - 600 ) )
$url = "https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=theanand";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
if ($data) {
preg_match('/circulation="([0-9]+)"/',$data, $matches);
if ($matches[1] != 0)
$fb['count'] = $matches[1];
$fb['lastcheck'] = mktime();
if($fb['count']==0) $fb['count']=$nulll;
echo 'Join my '.$fb['count'].'Subscribers';

I have added the cache code into the original code for easy implementation, again, thanks to Yoast!Remember to add the php hooks into the code before you save it.

If you, like me, migrated to google subdomain of feedburner and had your awareness API, check out this post by Yoast which explains what has changed with the feedburner API.