Display Google Feed Subscriber Count in Text

We previously showed how you can display Feedburner feed count in raw text. However, if you’ve recently migrated your feed from Feedburner to Google Feed, you’ll noticed those codes will no longer work. Here’s the workarounds, for those who wanted to display Google Feed subscriber count in text for better styling.

Previous Code For Feedburner…

This code will only work if you intend to display Feedburner feed count in text, but for those who are already on Google Feed, some changes are required.

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

The Solution

Replace line:2 from:

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

to the following:

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

The Complete Code

Here’s the complete set of code to display Google Feed subscriber count in text. Remember to replace feedburner-id (line:2) with your real feed ID.

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

Troubleshoots

Here are some of the possibilities if the above code don’t work for you:

  • Double check if you’ve correctly replaced http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id with https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=feedburner-id
  • Did you replaced feedburner-id with your actual Feed ID?
  • SimpleXMLElements requires PHP5. If nothing shows up, chances are your web host is still on PHP4. You should contact them about the upgrade.
WebsiteFacebookTwitterInstagramPinterestLinkedInGoogle+YoutubeRedditDribbbleBehanceGithubCodePenWhatsappEmail