Article written

  • on 27.04.2007
  • at 01:00 AM
  • by admin

Google AJAX Feed API 0

Abr27

Hace poco salio Google AJAX Feed API, esta rebueno para leer RSS o Atom sin la necesidad de hacerlo con librerias como Magpie para PHP… nos evitamos alojarlo x’D porque solo usamos un codigo muy corto y simple en javascript :D
Google Code!Solo debes registrarte, tomar tu key y listo… el API puede regresar los datos en formato JSON y XML (tambien se pueden combinar) aparte esta la documentacion para la clases y todo eso.

La forma mas sensilla de hacer uno… me tinca asi:

HTML:

  1. <script type=“text/javascript”>
  2. google.load("feeds", "1");
  3. function initialize() {
  4.     var feed = new google.feeds.Feed("http://www.lml.cl/blog/?feed=rss2");
  5.     feed.load(function(result) {
  6.     if (!result.error) {
  7.     var container = document.getElementById("feed");
  8.     var html="";
  9.     html+="<ul>";
  10.     for (var i = 0; i <result.feed.entries.length; i++) {
  11.         var entry = result.feed.entries[i];
  12.         html+=‘<li>‘;
  13.         html+=’<p>‘;
  14.         html+=’<a href="’+entry.link+‘" target="_blank">‘+entry.title+’</a>‘;
  15.         html+=’<br />‘;
  16.         html+=entry.contentSnippet;
  17.         html+=’</p>‘;
  18.         html+=’</li>‘;
  19.     }
  20.     html+="<ul>";
  21.     container.innerHTML=html;
  22.     }
  23. });
  24. }
  25. google.setOnLoadCallback(initialize);
  26. </script>

facil no? se interpreta asi
Cualquier sugenrencia su güen comment no mas x’D

subscribe to comments RSS

There are no comments for this post

Please, feel free to post your own comment

* these are required fields