Sharing your Google reader shared items

I use Google reader all the time, and its cool sharing items that you read about. The only problem is I don’t know many people that use Google Reader and therefore not that many of them see what I share.

So how can we get around this? Well I found out thanks to this website that you can get a RSS feed for your shared items! So I could just hand that out to people but, it would be nice to display it somewhere. So I thought why stop there? My url incase you want to know is:

http://www.google.com/reader/public/atom/user/01019558499128141290/state/com.google/broadcast

So, I then decided to use the Google AJAX Feed API and very simply I used this little bit of JavaScript to handle it.

  1. // load the feed API
  2. google.load("feeds", "1");
  3.  
  4. function ajax_feed() {
  5.   var feed = new google.feeds.Feed("long url that messed up my formatting :)");
  6.   feed.load(function(result) {
  7.     if (!result.error) {
  8.       var container = document.getElementById("feed");
  9.       var newHTML = ‘<ol style="padding-left: 20px;">’;
  10.       for (var i = 0; i < result.feed.entries.length; i++) {
  11.         var entry = result.feed.entries[i];
  12.         newHTML += ‘<li><a href="’+entry.link+‘">’ + entry.title + ‘</a></li>’;
  13.       }
  14.       newHTML += ‘</ol>’;
  15.      
  16.       if(container.innerHTML != newHTML) {
  17.         container.innerHTML = newHTML;
  18.       }
  19.      
  20.     }
  21.   });
  22.  
  23.   setTimeout(ajax_feed, 5000);
  24.  
  25. }
  26.  
  27. window.onload = ajax_feed;

This code basically loads up the feed with Google’s API. It then displays it on the page, easy as that. I added in a 10s loop to keep it refreshing.
I’ve added this to the sidebar of my blog; you can see it on the right, under my latest visitors list!
One of the really cool things about mash-ups like this is how easily I can integrate new systems.

Leave a Reply