» October 7, 2007 in
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.
koen () says on October 7, 2007:
Great idea, and another great tutorial Mark ;)However, it now says "Over 648" while you have 648. Over 648 means 649 or more :P
Thomas (babelhut.com) says on October 7, 2007
That's pretty cool. But you use the chicklet too. Why's that?
meilbeck () says on October 7, 2007:
Does this mean you will be implementing rss count into the top100 list ? ;)45n5 () says on October 7, 2007:
@koen - thanks it's fixed now@thomas - Just in case people need the "familiar" looking chicklet.
@meilbeck - Probably not. Because not everybody uses feedburner it would be like comparing apples to oranges, and I don't think people should get any bump for simply using feedburner.
newsniche () says on October 8, 2007:
As usual, you the man. You've either got way too much time on your hands or you are extremely productive.45n5 () says on October 8, 2007:
@newsniche - I'd like to think extremely productive.Vlad says on October 8, 2007
Mark,
As you know I have upgraded to PHP5, however it seams that certain calls to API require version 5.2 while mine is only 5.1.6, I was wondering if this code will work on 5.1.6?
45n5 () says on October 8, 2007:
@vlad - the api call doesn't require php 5, that uses Curl which was available earlier.Parsing the response requires any version of php five.
Specifically SimpleXML was introduced in php5 and I use one of it's funcions
SimpleXMLElement
Travel Blog says on January 19, 2008
First: What plugin or trick do you use to insert php code in a page/post? Please explain
Secondly: I tried to use a plugin, but then my html page stop showing right before where starts your code..
PS: I cannot subscribe to the comment of your post so please reply by email (too).
Thank you,
Cheers,
Tom
picard102 says on March 15, 2008
I also tried to use the code here and it didn't work. It dies after $xml = new SimpleXMLElement($data);
You can see it here http://www.usshyphron.com/Press/
Justin says on April 7, 2008
Hey thanks, this is exactly what I needed.


