How To Display Feed Count For Google FeedProxy In Text

January 8th, 2009 in Articles, News, WordPress by

Everyone knows that feedburner had merged with Google. This also lead to the previous feed counter in text doesn’t work. I just found out the solution for whoever is using feed counter in text with feedburner before and now converted into Google FeedProxy. Thanks to one of my user of “Our Community” – mtsandeep.

To Display Feedburner Subscriber Count In Text

Copy paste the following code into your template, replace feedburner-id with your Feedbuner username.

//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id";

//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

Paste this anywhere you want and it’ll display a Feedburner subscriber count in text.

echo $fb;

To Display Feed Counter For Google FeedProxy In Text

Use the previous code. Change this:

$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id";

Into This:

$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=feedburner-id"; 

Full Code:

//get cool feedburner count
$whaturl="https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=feedburner-id"; 

//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
add RSS

Comments

New to Old.
  • http://www.kailoon.com Jan 20, 2009

Reply

Write your comment here...




XHTML::
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Dribbble

Some of my recent works from dribbble, do check it out and leave me some feedbacks! Or follow me on dribbble and get updated.