How To Display FeedBurner Subscribers Count using PHP
You might have seen several blogs and websites showing off their Subscribers count from FeedBurner and you must be wondering how to do the same on your blog. Well, Here’s how :
1. First you need to activate the FeedCount Service on your FeedBurner account. You can do this by logging in to your Feedburner account (http://feedburner.google.com/) and then clicking on the name of the Feed for which you need the count to be displayed.
2. Next, goto Publicize -> FeedCount -> Activate (If you haven’t already activated it).
Next, we need to get the count from the FeedBurner Awareness API (https://developers.google.com/feedburner/awareness_api) to display it on our blog :
1. Open your code editor for your page and copy this code onto it :
This code will number of subscribers your feed has got and output it as HTML to your page.
<?php //Define the URL $FeedBurnerURL="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=YOURFEEDBURNERID"; //Initiate a Curl session $curlsess = curl_init(); //Set curl not to print the data which is received curl_setopt($curlsess, CURLOPT_RETURNTRANSFER, 1); //Set the URL curl_setopt($curlsess, CURLOPT_URL, $FeedBurnerURL); //Execute the CURL session $returnedData = curl_exec($curlsess); //Close the connection curl_close($curlsess); //Parse the XML Output and get the value from the circulation attribute $xml = new SimpleXMLElement($returnedData); $count = $xml->feed->entry['circulation']; // Print the FeedBurner Count echo $count . " subscribers"; ?>
The Embed Code Way :
You can display static or animated boxes (called as chicklets) to show your subscribers count by embedding the code from the FeedCount Page from your Feedburner Page which may look like this :
<p><a href="http://feeds.feedburner.com/TechTwinklers"><img src="http://feeds.feedburner.com/~fc/TechTwinklers?bg=99CCFF&fg=444444&anim=0" height="26" width="88" style="border:0" alt="" /></a></p>