This is a short tutorial explaining how to get the raw number of subscribers from your Feedburner feed to display on your web page.
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.
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.
To see an example of this view the demo below. I hope you find this little trick useful.