Monday, April 2, 2012

Google Feed API

With Google Feed API, you can download any public Atom, RSS, or Media RSS feed using only JavaScript.

The Google Feed API takes the pain out of developing mashups in JavaScript because you can now mash up feeds using only a few lines of JavaScript, rather than dealing with complex server-side proxies. This makes it easy to quickly integrate feeds on your website.

Example:
Google Feed API

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

    google.load("feeds", "1");

    function initialize() {
      var feed = new google.feeds.Feed("http://feeds.feedburner.com/Mobile-web-app");
      feed.setNumEntries(10);
      feed.load(function(result) {
        if (!result.error) {
          var container = document.getElementById("feed");
          for (var i = 0; i < result.feed.entries.length; i++) {
            var entry = result.feed.entries[i];
            var div = document.createElement("div");

            var A = document.createElement("A");  
            A.setAttribute("href",entry.link);  
            A.appendChild(document.createTextNode(entry.title));  
            div.appendChild(A);
            
            container.appendChild(div);
          }
        }
      });
    }
    
    google.setOnLoadCallback(initialize);

    </script>
  </head>
  <body>
    <h1>Mobile-web-app: Google Feed API</h1>
    <div id="feed"></div>
  </body>
</html>

No comments:

Post a Comment