首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google Feed API

Google Feed API
EN

Stack Overflow用户
提问于 2011-05-15 13:38:41
回答 1查看 1.3K关注 0票数 0

我在让Google的load feed工作时遇到了麻烦。示例应该在www.eslangel.com上

我把这个代码放在头文件里

代码语言:javascript
复制
<script type="text/javascript" 
src="https://www.google.com/jsapi?key=ABQIAAAAO2BkRpn5CP_ch4HtkkOcrhQRKBUhIk5KoCHRT6uc9AuUs_-7BhRyoJdFuwAeeqxoUV6mD6bRDZLjSw">
</script>

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

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

代码语言:javascript
复制
/*
*  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);​
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-05-15 16:26:52

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

试着放置

代码语言:javascript
复制
<div id="content"></div>

在提要加载脚本之前。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6006718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档