Display Google Feed Subscriber Count in Text

Advertisement


subscriber feed 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.

Related Contents

Sponsors

Posted by hongkiat in How-To , at 01.22.09

Tags: , , , , , , ,

Comments

  1. dev January 22nd, 2009

    Wow, thank man

    Reply
  2. DKumar M. January 22nd, 2009

    Nice Tutorial Mate, Thanks For sharing !!!

    Reply
  3. Sean Hurley January 22nd, 2009

    Hey, ,, maybe i have missed the post but do you ever show someone an simple way to customize the feed burner subscribe tool? Without any design its just submit email here and a text field.

    Reply
  4. David Pierce January 23rd, 2009

    Thanks for this tutorial! A number of my favorite blogs have this feature, and it’s far more attractive when it’s written out as opposed to the little Feedburner chicklet.

    Well-written, and bold to try troubleshooting beforehand. Thanks!

    Reply
  5. Amirez January 23rd, 2009

    thanks a lot man. this what i looking for a long time. great tutorial

    Reply
  6. Vikram January 23rd, 2009

    How do i do this with my blogger based blog man?

    Reply
  7. hongkiat January 23rd, 2009

    @Vikram Here’s something for the blogger. http://tinyurl.com/7q7bn6. I’ve not try them personally but hope it still works :-) Remember to change the feedburner URL to Google Feed.

    Reply
  8. Paul Tan January 24th, 2009

    You can use this for blogger.

    google feedburner: http://www.feedtxt.com/gf/your feed id here/show.js

    feedburner: http://www.feedtxt.com/fb/your feed id here/show.js

    for example, for your blog…

    http://www.feedtxt.com/gf/nampblog/show.js

    Reply
  9. Woodstock Real Estate January 25th, 2009

    Thanks Hong, this tutorial is much easier to follow than the other ones that I have found. You are a great communicator!

    Reply
  10. Jen January 25th, 2009

    Nice! This will definately help me gain more subscribers…

    Reply
  11. Best Design Options January 25th, 2009

    This is actually what I’ve been looking for! Thanks for this very useful post!

    Reply
  12. Rahul January 25th, 2009

    Hey man, all the hard work done by Hongkiat. We just need to do is copy & paste only. Thanks for all the codes. Cheers.

    Reply
  13. Yong How January 26th, 2009

    Nice one. thx for sharing the codes. I just need it for my blog.

    Reply
  14. ironman January 27th, 2009

    this is very nice hint

    Reply
  15. Atlanta Georgia Real Estate February 3rd, 2009

    These codes are great. I incorporated them already on one of my sites already!

    Reply
  16. Danial March 8th, 2009

    Thanks For This Post .

    Reply
  17. Jack November 2nd, 2009

    Nice codes, thank you!

    Reply

Leave a reply