Google Feed API

时间:2011-05-15 05:38:41

标签: javascript api rss google-feed-api

我无法让Google的加载Feed工作。示例应该是www.eslangel.com

我把这段代码放在标题

<script type="text/javascript" 
src="https://www.google.com/jsapi?key=ABQIAAAAO2BkRpn5CP_ch4HtkkOcrhQRKBUhIk5KoCHRT6uc9AuUs_-7BhRyoJdFuwAeeqxoUV6mD6bRDZLjSw">
</script>

然后,为了测试,我使用Digg Feed将他们的示例代码复制并粘贴到我的博客正文中,但没有任何结果。

有没有人知道我可能做错了什么?

/*
*  How to load a feed via the Feeds API.
*/

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

// Our callback function, for when a feed is loaded.
function feedLoaded(result) {
  if (!result.error) {
    // Grab the container we will put the results into
    var container = document.getElementById("content");
    container.innerHTML = '';

    // Loop through the feeds, putting the titles onto the page.
    // Check out the result object for a list of properties returned in each entry.
    // http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON
    for (var i = 0; i < result.feed.entries.length; i++) {
      var entry = result.feed.entries[i];
      var div = document.createElement("div");
      div.appendChild(document.createTextNode(entry.title));
      container.appendChild(div);
    }
  }
}

function OnLoad() {
  // Create a feed instance that will grab Digg's feed.
  var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");

  // Calling load sends the request off.  It requires a callback function.
  feed.load(feedLoaded);
}

google.setOnLoadCallback(OnLoad);​

1 个答案:

答案 0 :(得分:1)

那么,您是否也为Feed创建了一个容器? : - )

尝试放置

<div id="content"></div>

在Feed加载脚本之前。