This is a short tutorial explaining how to get the raw number of subscribers from your Feedburner feed to display on your web page.

Intoduction

To do this simple trick we are going to use three things:

  • Feedburner Awareness API (which you don’t need to activate for this)
  • cURL (should be enabled on most servers)
  • PHP 5 (to read the XML we need a PHP5+ function)

I’m assuming here you have a Feedburner account with an active feed.

The PHP

So onto the php.

<?php
$feeduri = "progtuts"; //The bit that comes after http://feeds.feedburner.com/
//This is the old Feedburner url
//$url = "http://api.feedburner.com/awareness/1.0/GetFeedData?uri=". $feeduri;
//This is the new Google Feedburner url
$url="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=". $feeduri;
$ch = curl_init(); //Use cURL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Return data rather then echo it
curl_setopt($ch, CURLOPT_URL, $url); //Pass in our url
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXMLElement($data); //Read the returned XML
$count = $xml->feed->entry['circulation']; //Get our subscriber count
?>

Thats it. Very simple. All we are doing here is using cURL to retrieve the XML output by the Feedburner API and convert it into a php variable. You can now use $count however you want.

Conclusion

To see an example of this view the demo below. I hope you find this little trick useful.

View the Demo

Related Posts

More?

If you enjoyed this post, please consider promoting it.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Design Float
  • Reddit
  • Mixx
  • Technorati

Remeber to subscribe to the feed and get future articles delivered to your feed reader.

If you want to discuss this tutorial or any other thoughts you have then you can do so over on our fourm.

Comments

  1. This no longer works, according to your demo page. it says that there is a fatal exception.

  2. it’s works for my browser…

  3. I fixed the script so it should work now.

Leave a Comment

(required)

(required)