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);
curl_close($ch);
if ($data) {
preg_match('/circulation="([0-9]+)"/',$data, $matches);
if ($matches[1] != 0)
$fb['count'] = $matches[1];
$fb['lastcheck'] = mktime();
update_option("feedburnersubscribecount",$fb);
$nulll='N/a';
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.


For updates on Display Feedburner Subscriber Count
Enter your email here:

6 Comments

Leave a Comment · TrackBack · RSS Comments

  1. Hey, When Google introduced ads to feeds, I just gave the origional feed source (millionclues.com/feed) to adsense and changed the feedburner source to the feed of adsense. (the one that starts with feedproxy.google

    That means my content will go to adsense first, get the ads inserted and this will go to feedburner (along with the ads)
    So everything was working as usual, didnt have to change anything.

  2. Comment by Anand on December 27, 2008

    but the awareness api was broken when that happened and hence my subscriber count sucked too…also, the email subscribers cannot be exported in the new one.

  3. Thanks,

    I also got this working on my blog with the cache. It is great it works again as I love my little feed icon.

    Thanks,

  4. Comment by Anand on January 1, 2009

    Indeed, it looks beautiful with that cute icon…I might just steal that for my blog too :D

  5. Comment by TC on February 14, 2009

    Thanks for the code! I finally got this working (there was a problem with the ” ‘ in the c&p, I just replaced them and then they worked)…I’m not a php code expert btw ;) .

    Question: I have thousands of subscribers and I’d like to have the count displayed this way:

    x,xxx rather than xxxx

    Is it possible to add a comma somehow?

  6. Comment by Anand on February 14, 2009

    That would be possible by changing the number into integers…like ones tens and hundreds and adding a comma after that.

Leave a comment

Get Adobe Flash playerPlugin by wpburn.com wordpress themes