Get Your FeedBurner Reader Statistic Using PHP cURL and the FeedBurner API

By  on  

My favorite part of the Web 2.0 revolution is the abundance of APIs. Everyone has one: Digg, Feedburner, Pownce, Flickr, Google Maps, etc. FeedBurner provides a sweet "Awareness API" that allows you to pull statistics from your FeedBurner account. Here's how you do it using PHP cURL.

The PHP

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,'http://api.feedburner.com/awareness/1.0/GetFeedData?id=#######');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);

//execute post
$content = curl_exec($ch);

$subscribers = get_match('/circulation="(.*)"/isU',$content);

echo 'Subscribers:  '.$subscribers;

//close connection
curl_close($ch);


/* helper: does the regex */
function get_match($regex,$content)
{
	preg_match($regex,$content,$matches);
	return $matches[1];
}

It's that easy. What makes this even better is that I hate FeedBurner's "badge" and I can manipulate the result of the above code any way I want. Click here to learn more about FeedBurner's Awareness API and the information you can pull about your feed.

Recent Features

  • By
    Send Text Messages with PHP

    Kids these days, I tell ya.  All they care about is the technology.  The video games.  The bottled water.  Oh, and the texting, always the texting.  Back in my day, all we had was...OK, I had all of these things too.  But I still don't get...

  • By
    CSS 3D Folding Animation

    Google Plus provides loads of inspiration for front-end developers, especially when it comes to the CSS and JavaScript wonders they create. Last year I duplicated their incredible PhotoStack effect with both MooTools and pure CSS; this time I'm going to duplicate...

Incredible Demos

  • By
    Morphing Elements Using MooTools and CSS

    Morphing an element between CSS classes is another great trick the MooTools JavaScript library enables you to do. Morphing isn't the most practical use of MooTools, but it's still a trick at your disposal. Step 1: The XHTML The block of content that will change is...

  • By
    AJAX For Evil:  Spyjax with jQuery

    Last year I wrote a popular post titled AJAX For Evil: Spyjax when I described a technique called "Spyjax": Spyjax, as I know it, is taking information from the user's computer for your own use — specifically their browsing habits. By using CSS and JavaScript, I...

Discussion

  1. Very nice; I would like this info, but I too hate the FeedBurner badges.

  2. Nice!! I was considering finally putting my subscriber count on my site and you just made it a bit easier. Thanks!

  3. Stuart

    Nice article, although not sure if i’ll be running it until I relaunch my blog with more than two subscribers.

  4. Nice, i try it soon. thank you.

  5. How can I use this same thing when m account is with google feedburner? feedburner.google.com

  6. Hi David,
    Can I check that if an email address is subscribed to my feeds or not?

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!