Skip to the content...

Welcome to the David Walsh Blog. I'm a MooTools, Dojo, jQuery, CSS, and PHP Web Developer located in Madison, Wisconsin, United States. Please contact me if I can make your experience on my website better.

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

8 Responses »

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.

Discussion

  1. July 24, 2008 @ 10:38 am

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

  2. July 24, 2008 @ 10:42 am

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

  3. stuart
    July 26, 2008 @ 7:35 am

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

  4. August 3, 2008 @ 1:03 pm

    Nice, i try it soon. thank you.

  5. November 1, 2008 @ 12:46 am

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

  6. June 12, 2009 @ 7:25 am

    thankyou very much, from one web developer to another, will defo use…when i get more than one subscriber to my photo blog that is. lol cheers matthew

Be Heard!

Share your thoughts with fellow developers of all skill levels! I want to hear from you!

Name*:
Email*:
Website:  
Wrap your code with <code> tags, f00!