FeedBurner subscription show-off revisited

A couple of months back I blogged about how to show off your FeedBurner subscribers. In the comments then, a couple of people told me the code didn’t work for them. After a few back and forths I found out those people were on FeedBurner’s new servers, the Google ones.

This new server actually has a new API Endpoint as well, and this endpoint brings along a bit of trouble. Google in all its wisdom decided to move the API onto HTTPS. Problem is, I was using Snoopy, which rocks, but doesn’t work with HTTPS easily. It needs CURL for that, and if it needs CURL anyway, why not use the built-in PHP CURL. So, here’s the code to use when you’re on feedproxy (if this doesn’t work for you, try the above linked older code):

$url	= 'https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=joostdevalk';
$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);
}
echo $fb['count'].' Subscribers can\'t be wrong! Subscribe by <a href='http://yoast.com/email-blog-updates/'>email</a> or to the <a rel='nofollow' href='http://feeds.feedburner.com/joostdevalk'>RSS feed</a> now!';

Enjoy!

Tags: ,


Yoast.com runs on the Genesis Framework

Genesis theme frameworkThe Genesis Framework empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides you with the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Read our Genesis review or get Genesis now!

22 Responses

  1. slobjonesBy slobjones on 21 December, 2008

    Funny you should be promoting FeedBurner.

    I started using your Sociable plugin after FeedBurner abandoned support for its FeedFlare script. Didn’t bother to tell anybody — just abandoned it.

    You sure you want to help these guys?

  2. SebBy Seb on 22 December, 2008

    The original feeburner display counter you posted, 3 times it failed to load the api and diplayed a bunch of errors before the rest of my blog had loaded. Is this because of the new servers and connetion took a bit longer than it should have? I will try your new code, but so far I have had no problems again but I don’t want any more loading problems so if it comes up again I will post again with the reason the code did not load.

  3. Andrew MasonBy Andrew Mason on 22 December, 2008

    I have been having this issue since moving to Feedproxy so I will try to get it working on my blog. Thanks Joost!

  4. TheAnandBy TheAnand on 23 December, 2008

    You have a extra closing bracket on the second last line…..otherwise…it works great!!!

    Thanks!

  5. Andrew MasonBy Andrew Mason on 23 December, 2008

    Got it working great at http://www.didigetthingsdone.com.

    Thanks for the help. I did need to add an extra opening bracket after the second if statement but apart from this, it all works a treat and looks nice again on my blog.

    Thanks!

  6. Andrew MasonBy Andrew Mason on 23 December, 2008

    I spoke too soon.

    All worked fine, then it just stopped? Now, $fb[‘count’} has a null value. The strange thing is that it worked fine for 15 minutes..

    • Joost de ValkBy Joost de Valk on 23 December, 2008

      Check out my previous post and steal the caching I used there :)

      • Andrew MasonBy Andrew Mason on 23 December, 2008

        Thanks,

        Just trying that now.

      • Andrew MasonBy Andrew Mason on 23 December, 2008

        I cut the caching code and all works fine.

        Thanks, this looks great again on my blog!

        Have a great Christmas!

      • Jesh BarlowBy Jesh Barlow on 3 April, 2009

        Sorry, designer here, not a developer. I’m a bit worried that I’ll have Andrew’s same problem, but I have no clue how to paste in the caching from the previous link. Did you already update the above code to include the same caching as the previous solution, or do I need to somehow use the mktime() < 600 line? I’m just totally ignorant of the syntax.

        Thanks for your help!

  7. NiharBy Nihar on 25 December, 2008

    Joost, thanks for this tiny curl script. I will use this to show off the subscription.

  8. NiharBy Nihar on 25 December, 2008

    My subscribers shows 900 odd. but when i open this https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=ThinkersOnMove link in browser. It shows circulation=”0″ . Any reason why?

  9. JauhariBy Jauhari on 30 December, 2008

    Let’s me test the new one ;)

  10. AjayBy Ajay on 30 December, 2008

    Works great. Can you write about caching the queries?

  11. TheAnandBy TheAnand on 30 December, 2008

    This same code with the cache implemented is in my blog in case anyone is looking for a easy copy paste of this method code!!

    http://www.theanand.com/blog/index.php/just-ripples/display-feedburner-subscriber-count/

  12. SDKBy SDK on 11 March, 2009

    this stopped working for me all of the sudden – nothing displays
    i reverted back to the old show off code, it works, but shows an incorrect subscriber count

  13. JeromeBy Jerome on 14 March, 2009

    Can’t get to work. Nothing displays, I tried both code.

Trackbacks