Posterous theme by Cory Watilo

Get subscriber count with feedburner API

Today, I want to add feed count from feedburner , in my blog. So, I need to write code using feedburner api. It's not easy.
  1. login your feedburner and go to your feed.
  2. Go to Publicize tag
  3. Go to Awareness Api and active it.
Now, time for coding. change your id in uri of $toopen. In the code, I use saturngoden.
<?php
//get cool feedburner count
$toopen="http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=saturngoden";

$ch = curl_init(); /// initialize a cURL session
curl_setopt($ch, CURLOPT_URL, $toopen );
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec ($ch);//end get cool feedburner count
curl_close($ch);

$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->loadXML($content);
$count=$dom->getElementsByTagName("entry")->item(0)->getAttribute("circulation");
echo $count;
?>
Posted | Viewed
 times
Filed under: