Embed google reader feed into webpage

Posted by Andi Syahputra | 3:01 PM
Google reader is a one of famous RSS reader developed by google. With google reader you can susbcribe to many types of RSS feed out there just with single click. So, you can see the update of your favorite website without go to their homepage. Now I will show you the tutorial about how to embed your subscribed feed in google reader directly to your webpage.

Perhaps you already read my previous post about embed RSS as a javascript to your site. Now I'll talk about the similar thing, but we use google service here to deliver your feed with javascript. It's small file so don't worry about your page load time after you use this script.
OK, here is the step by step procedure:
1. Go to your google reader. Drag your feeds into a folder.
For example I use FUN-TUTORIAL as my folder name. It contains this blog feed. You can add more than one feed to the folder.

2. Go to reader settings in the top right of the page.
Choose folders and tags tab. Then you can find the folder you just created.
Click to enlarge... :D

Click the "private" icon, then it will change to public. Your feed will be public access and had their URL in the view public page.
Here is my blog feed.

3. Create a javascript snippet to embed that feed into your webpage.
Click add a clip to your site link. Then the script will appear
Copy the selected javascript, until the question mark... :D


Now we use a cool hack that I found, it will reduce the javascript file.
here is the script:

<script type="text/javascript">
window.ContainerID = "";
function FormatGoogleClip (blog) {
var container=document.getElementById(window.ContainerID);
var code="<ul>";
for (var i = 0; i < blog.items.length; i++) {
var item = blog.items[i];
code=code+"<li><a href='"+item.alternate.href+"' target='_blank'>" + item.title + "</a></li>";
}
code=code+"</ul>";
container.innerHTML=code;
}
</script>

Put it in the <head> tag.

Then put this tag in <body> wherever you want it to appear:
<div id="YourFeed"></div>
<script type="text/javascript">window.ContainerID="YourFeed";</script>
<script type="text/javascript" src="http://www.google.com/reader/public/javascript/user/00906281199229763029/label/FUN-TUTORIAL?n=5&callback=FormatGoogleClip"></script>

Change the address http://www.google.com/reader/public/javascript/user/00906281199229763029/label/FUN-TUTORIAL with your own feed URL.
n = 5, is a number of post. You can change in to any number you want.

This will generate only 5KB of javascript for 5 links. It's very small size right? I'm sure it won't impact your site performance.

Ok, that's it..... If you had a question just post your comment below... :D
hi folks, visit my other tutorial blog at Kumpulan tutorial menarik
1 comments
  1. WiseManWhite October 18, 2011 at 8:48 AM  

    I still can't get this to work. Blogger wont allow me to put code in the comments. Is this something that Google no longer allows?

    Thanks!
    - WiseManWhite