How To Get Your Feedburner Count As Plain Text

How To Get Your Feedburner Count As Plain Text

Do you want to get your feedburner count in plain text instead of their chicklet? Want that text to update dynamically so every time the feedburner count changes the text changes on your blog? Read on…

Getting your feedburner count as plain text gives you the flexibility to do whatever you want with it.

For instance my blog says “Subscribe Now: Over 648 readers can’t be wrong!” where the 648 automatically changes every time my feedburner count updates. Pretty cool. Certainly you didn’t think I was manually updating that did you? ;-p

Disclaimer: The following requires a basic understanding of where to place php code in your template and works on servers with PHP 5. Also, whenever working with files ALWAYS back them up before modifying them.

How To Get That Feedburner Count As Text Only

Overview

Make a call to the Feedburner API requesting the feedcount for a given burned feed.

Output the count. Thats it 😉

The Details

Place the following code in your template before where you want to display the count. This will get your feedcount from feedburner. Replace rss4real with the name of your feedburner feed.

<?php
//get cool feedburner count
$whaturl=”http://api.feedburner.com/awareness/1.0/GetFeedData?uri=rss4real”;

//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
?>

Now we’ve got your feedcount in a variable called $fb. Wherever you want to output your feedcount simply drop in the following code:

<?php echo $fb;?>

The How To Get Your Feedburner Count As Plain Text Conclusion

That’s all she wrote. To see this code in action simply visit my blog at 45n5.com and check out the subscribe box.

If you like this post then please consider subscribing to my full RSS feed. You can also Subscribe to 45n5 by Email and have new posts sent directly to your inbox.