Sitenotes for your blog, Google style

Posted by tobi — 08:53 AM Apr 19

  1. Sign up to use Googles newly released Feed API
  2. Follow the instructions to include their javascript correctly
  3. Create a ul called shared-posts in your sidebar
  4. Sign up for Google reader
  5. Share some posts
  6. Note down the url of your shared articles feed
  7. Add following javascript to your blog:

var Sitenote = {
  fromGoogle: function(result)  {
    var feed = new google.feeds.Feed("http://www.google.com/reader/public/atom/user/...");
    feed.load(function(result) {
      if (result.error) { return; }
      var container = document.getElementById("shared-posts");
      for (var i = 0; i < result.feed.entries.length; i++) {
        var entry = result.feed.entries[i];
        var li = document.createElement("li");
        var link = document.createElement('a');
        link.href = entry.link;
        link.title = entry.title; 
        link.appendChild(document.createTextNode(entry.title));
        li.appendChild(link);
        container.appendChild(li);
      }
    });
  }
};

google.load("feeds", "1");
google.setOnLoadCallback(Sitenote.fromGoogle);

Comments

  • masukomi 19 Apr 11:19

    While this is cool, and I appreciate your posting it, there’s an easier way. Sign up for Google Reader, click on Shared Items, click on the link under “Put a clip on your site or blog” and cop paste the html it provides you. :)

  • tobi 19 Apr 12:05

    Uh. true.

    Well this method lets you customize the appearance of the feed for what its worth.

  • Ibrahim 19 Apr 13:12

    Well, Google Reader webclips are easier and customizable, but for Google to have a whole API for feeds, that’s genuine. I like it, at least it should keep my server free from fetching and caching the feeds i use in my websites.

  • Hello 20 Apr 21:36

    Hi

  • Patch 14 May 13:23

    hm, and u didn’t know it before?

Commenting are now closed…