Making Your Own FeedBurner Chicklet (PHP)
Filed under PHPThe FeedBurner Chicklet is a great tool for publishing your feed, it does look a bit ugly though. By using the powerful FeedBurner API you can grab your feed count without the Chicklet. This means you can put it anywhere on your site!
Step 1: What you need
We are going to be using PHP’s cURL library, which means, full details on what you need for this package can be found on php.net. You will also need your FeedBurner URL.
Step 2: The Code
First of all we need to create the URL to the data for our feed. We are using the FeedBurner Awareness API to get the data. The API call is made up of 2 parts, the first being the call to FeedBurner, the second being the name of your feed (in FeedBurner).
$feed="http://api.feedburner.com/awareness/" .
"1.0/GetFeedData?uri=YOURFEEDNAME";
Next we need to start our cURL session by initialising the PHP curl_init() call.
$curl = curl_init();
We use CURLOPT_RETURNTRANSFER to make sure the data is returned instead of being printed out to the browser. After we have done that we can set the optiona for the curl.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // Set the URL of the curl set options curl_setopt($curl, CURLOPT_URL, $feed); // Execute the fetch $data = curl_exec($curl); // Close the connection curl_close($curl);
After we have got the data we can parse the XML and find the bit we are looking for (circulation).
$xml = new SimpleXMLElement($data); $feed = $xml->feed->entry['circulation'];
Step 3: Putting It All Together
$feed="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=dtsn"; $curl = curl_init(); curl_setopt($curl , CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl , CURLOPT_URL, $feed); $data = curl_exec($curl ); curl_close($curl ); $xml = new SimpleXMLElement($data); $feed = $xml->feed->entry['circulation'];
The subscription count is included in the variable $feed, which you can put anywhere. Or if you don’t have any imagination like me you can just put it in your side bar. It makes a great alternative to the Chicklet.


