Get your average Feedburner subscribers


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function get_average_readers($feed_id,$interval = 7){
  2. $today = date('Y-m-d', strtotime("now"));
  3. $ago = date('Y-m-d', strtotime("-".$interval." days"));
  4. $feed_url="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=".$feed_id."&dates=".$ago.",".$today;
  5. $ch = curl_init();
  6. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  7. curl_setopt($ch, CURLOPT_URL, $feed_url);
  8. $data = curl_exec($ch);
  9. curl_close($ch);
  10. $xml = new SimpleXMLElement($data);
  11. $fb = $xml->feed->entry['circulation'];
  12.  
  13. $nb = 0;
  14. foreach($xml->feed->children() as $circ){
  15. $nb += $circ['circulation'];
  16. }
  17.  
  18. return round($nb/$interval);
  19. }

URL: http://www.catswhocode.com/blog/10-life-saving-php-snippets

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.