Simple Feedburner Ticker with PHP
Feedburner provides a simple Ticker applet for display in your pages and elsewhere. This always worked fine for me until I transferred my feed to Google.
Now I love what Google is doing, like free-ifying all of the Pro services, but I really depended on that simple ticker to know where my feed stood.
If you found that the Feedburner ticker is no longer working for you (make sure you add your feed’s uri to the end), I offer my solution as a replacement. At least until they update the applet.
First I suggest you try the existing Feedburner Ticker before using this. If it shows 0 0, then keep on reading.
Problem
The Feedburner provided Ticker applet no longer provides accurate data for you. I noticed the issue immediately after transferring my feed to Google.
Solution
By leveraging the provided Awareness API, some xml parsing and a short php snippet we can build a similar widget in no time.

THe Steps to Build your Own Feedburner Ticker
Prerequesites
First you need to login into your feedburner/google account and be sure you have activated the Awareness API. Its under the Analyze tab.
Next you need to find 3 icon images to signify a positive change, negative change, or steady state. You can search Google images perhaps for a nice green up arrow, red down arrow etc.
Check the API
So I assume you have already tested that you are able to access the API right? Oh no? Well try this link, and add your feed uri to the end.
You should a nice XML formatted result like this;
<rsp stat="ok"> − <!-- This information is part of the FeedBurner Awareness API. If you want to hide this information, you may do so via your FeedBurner Account. --> − <feed id="m7ksd6fx8795fdchj9dthc" uri="EdwardAWebb"> <entry date="2009-01-25" circulation="23" hits="219" reach="7"/> </feed> </rsp>
As you can see my sites not so popular today
The Ticker Code
Since the xml above is rather dry we’ll want to spice it up a bit.
<?php /** * Feedburner ticker * written by Edward Webb http://edwardawebb.com January 22 2009 * license :GPL **/ //get needed values $uri=$_GET['fb_uri']; //as of current, Awareness API only supports yesterday and back http://code.google.com/apis/feedburner/awareness_api.html#dates $yest= date('Y-m-d',mktime(0, 0, 0, date("m"), date("d")-1, date("Y"))); $prev=date('Y-m-d',mktime(0, 0, 0, date("m"), date("d")-2, date("Y"))); $awApiUrl='https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri='.$uri.'&dates='.$prev.','.$yest.''; $link='<a href="'.$awApiUrl.'">link</a>'; //Initialize the Curl session $curl = curl_init(); //Set curl to return the data instead of printing it to the browser. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //Set the URL curl_setopt($curl, CURLOPT_URL, $awApiUrl); //Execute the fetch $data = curl_exec($curl); //Close the connection curl_close($curl); $xml = new SimpleXMLElement($data); $prevCount = $xml->feed->entry[0]['circulation'] + 0; $yestCount = $xml->feed->entry[1]['circulation'] + 0; switch(true){ case ($yestCount == $prevCount): $img='<img src="./nochange.gif" />'; break; case ($yestCount < $prevCount): $img='<img src="./arrow-down-red.gif" />'; break; case ($yestCount > $prevCount): $img='<img src="./arrow-up-green.gif" />'; break; default: echo "hmm.. Can't seem to do math on these figures. Check this ".$link." to make sure it looks like valid xml"; } ?> <table> <tr> <td></td><td style="text-decoration:underline;">Previous</td><td style="text-decoration:underline;">Yesterday</td><td></td> </tr> <tr> <td><?php echo $uri ?></td> <td style="font-weight:bold;" align="center"><?php echo $prevCount ?></td> <td style="font-weight:bold;" align="center"><?php echo $yestCount ?></td> <td align="center"><?php echo $img ?></td> </tr> </table>
Alright, now just save that code to your server, lets say http://example.com/feedticker.php and just append your URI…
http://example.com/feedticker.php?fb_uri=edwardawebb
Yeah its simple but sweet. I found the need to replace my Piwik Widget which is using the old Feedburner Ticker.

Plugin to add Feedburner widget to Piwik
If you would like to use this in you Piwik install just let me know and I’ll shoot the complete plugin over to you.
Updated Feedburner Ticker
I decided that I wanted to track the changes in Reach and Hits in addition to circulation. Ya know something that looked more like this;

Includes Hits and Reach
Yeah, that would be just dandy. If you feel like you want those counts as well than replace the code above with this snippet.
feedburnerTicker.php
<?php /** * Feedburner ticker * written by Edward Webb http://edwardawebb.com January 22 2009 * license :GPL **/ //get needed values $uri=$_GET['fb_uri']; //as of current, Awareness API only supports yesterday and back http://code.google.com/apis/feedburner/awareness_api.html#dates $yest= date('Y-m-d',mktime(0, 0, 0, date("m"), date("d")-1, date("Y"))); $prev=date('Y-m-d',mktime(0, 0, 0, date("m"), date("d")-2, date("Y"))); $awApiUrl='https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri='.$uri.'&dates='.$prev.','.$yest.''; $link='<a href="'.$awApiUrl.'">click</a>'; //Initialize the Curl session $curl = curl_init(); //Set curl to return the data instead of printing it to the browser. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); //Set the URL curl_setopt($curl, CURLOPT_URL, $awApiUrl); //Execute the fetch $data = curl_exec($curl); //Close the connection curl_close($curl); $xml = new SimpleXMLElement($data); $dataArr=array(); $i=0; foreach($xml->feed->entry as $feedDay){ $dataArr['Circulation'][$i]=$feedDay['circulation'] + 0; $dataArr['Hits'][$i]=$feedDay['hits'] + 0; $dataArr['Reach'][$i]=$feedDay['reach'] + 0; $i++; } ?> <table align="center" cellpadding="2"> <tr> <td></td><td style="text-decoration:underline;">Previous</td><td style="text-decoration:underline;">Yesterday</td><td></td> </tr> <?php foreach($dataArr as $key=>$value){ $img=''; switch(true){ case($value[0] == $value[1]): $img='<img src="./plugins/Feedburner/nochange.gif" alt="--"/>'; break; case($value[0] < $value[1]): $img='<img src="./plugins/Feedburner/arrow-up-green.gif" alt="^"/>'; break; case($value[0] > $value[1]): $img='<img src="./plugins/Feedburner/arrow-down-red.gif" alt="v"/>'; break; } echo '<tr>'; echo '<td style="font-weight:bold;">'.$key.'</td>'; echo '<td style="text-align:center;">'.$value[0].'</td>'; echo '<td style="text-align:center;">'.$value[1].'</td>'; echo '<td style="text-align:center;">'.$img.'</td>'; echo '</tr>'; } ?> </table>
Update
I have refactored the code about into a html template and php class that can be downloaded as a complete Piwik Plugin.
[download_cat#1]
Hi,
i just found your code while searching for the Feedburner-Piwik widget. So can you please mail me your code for a piwik widget?
Thank you in advance and excuse my, not so good, english.
Regards, Michael
@Michael
) @ dev.piwik.org.
If you check out the Trac site for piwik (which seems to be down right now
There you can search for the ticket I originally submitted that includes the code as I have it at this point.
Feel free to make imporvements as per the Piwik team’s feedback.
Just a follow up to Michaels question.
I decided to add the full plugin as a downloadable tar or zip file. See the the article for links.
@Eddie:
THX for putting it all together as a plugin. =)
Thanks, this is great!
Hi Edward,
i really would like to use your Plugin within my Piwik site.
Unfortunately it seems, that with piwik 1.0 there were some changes, therefore it’s throwing multiple error message, when I try to enable the plugin within the Dashboard.
Is there a chance to get an updated version of this plugin?
Regards
Stefan
@mySHAW I actually haven’t madeany change in a while. Having just installed 1.0 last week. Iii.net welcome to hack away at what it’s there though, cer if you can can resolve the incompatibilities.
Hi,
something I don’t get quite yet: Can I add a widget showing my rss feeds on my piwik site? It appears so hard for me to get piwik widgets.
Thanks