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);
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.


Comments

7 responses to “Display Feedburner Subscriber Count”

  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.

    1. 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.

  2. 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,

    1. Indeed, it looks beautiful with that cute icon…I might just steal that for my blog too 😀

  3. 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?

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

  4. Hello,
    The code is not working in my case. Not getting what is wrong? I have just copied and pasted the code on my header section, immediately after Facebook -icon.

    I have put the following URL.
    $url = “https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=myfeed6”;

    My Feed Address: http://feeds.feedburner.com/myfeed6
    Original Feed: http://appliedjung.com/feed

    Please suggest me what was the wrong in my code.
    Thank you

Leave a Reply

Your email address will not be published. Required fields are marked *