Thursday, December 24, 2009

Add Feedburner Subscriber Count In Text

Step 1

Copy paste the following code into your template, replace feedburner-id with your Feedbuner username. This script will grab you the feed count in numbers.

view plaincopy to clipboardprint?

//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=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'];

//end get cool feedburner count

//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=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'];

//end get cool feedburner count

Step 2

Paste this anywhere you want and it’ll display a Feedburner subscriber count in text.
view plaincopy to clipboardprint?

echo $fb;

To style it nicely with your website or blog’s theme, add or and tweak the CSS accordingly.

No comments: