Display Feedburner Subscriber Count as Text

Posted on March 11th, 2011

Have you ever been to a site that is not using Feedburner button and is still showing subscriber count? Well they are probably using the trick we are about to share. Most designers use this trick to have custom styling and avoid the annoying feedburner button.

Simply copy and paste this code anywhere you like most likely sidebar.php

<?php
 //get cool feedburner count
 $whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=your feedburner id";
//Initialize the Curl session
 $ch = curl_init();
//Set curl to return the data instead of printing it to the browser.
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Set the URL
 curl_setopt($ch, CURLOPT_URL, $whaturl);
//Execute the fetch
 $data = curl_exec($ch);
//Close the connection
 curl_close($ch);
 $xml = new SimpleXMLElement($data);
 $fb = $xml->feed->entry['circulation'];
 echo $fb;
 //end get cool feedburner count
 ?>