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.
-
// load the feed API
-
google.load("feeds", "1");
-
-
function ajax_feed() {
-
var feed = new google.feeds.Feed("long url that messed up my formatting :)");
-
feed.load(function(result) {
-
if (!result.error) {
-
var container = document.getElementById("feed");
-
var newHTML = ‘<ol style="padding-left: 20px;">’;
-
for (var i = 0; i < result.feed.entries.length; i++) {
-
var entry = result.feed.entries[i];
-
newHTML += ‘<li><a href="’+entry.link+‘">’ + entry.title + ‘</a></li>’;
-
}
-
newHTML += ‘</ol>’;
-
-
if(container.innerHTML != newHTML) {
-
container.innerHTML = newHTML;
-
}
-
-
}
-
});
-
-
setTimeout(ajax_feed, 5000);
-
-
}
-
-
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.
