我正在使用 google feed api。基本上我想要一个我的提要列表以及提要条目的一些信息,以便处理通常在谷歌阅读器上不可用的历史提要。我对 google feed api 的一种行为感到困惑,我在下面的代码中将其记录为注释。我确信我没有得到任何东西,因为我是 js 新手。
这是我的问题作为评论的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" charset="UTF-8" >
google.load("feeds", "1");
/* Here I define the list of my feeds */
var feeds=['MYFEED1', 'MYFEED2', 'AND SO ON'];
function initialize() {
for (var j=0;j<feeds.length;j++) {
var feed = new google.feeds.Feed(feeds[j]);
feed.includeHistoricalEntries();
feed.setNumEntries(100);
feed.load(function(result) {
if (!result.error) {
var container = document.getElementById("out");
var furl = result.feed.feedUrl;
var flink = result.feed.link;
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var div = document.createElement("div");
/* HERE IS WHERE I DON'T GET IT.
feeds[j] always just shows the last feed in the array.
But furl always shows the correct feedUrl
Though if I uncomment alert("NEXT") few lines below
thus giving a short pause, feeds[j] correctly
shows the same url as feedUrl. Why? */
div.appendChild(document.createTextNode(feeds[j]+" "
+furl+" "+flink+" "+ entry.link + " " + entry.title));
container.appendChild(div);
}
}
});
//alert("NEXT");
}
}
google.setOnLoadCallback(initialize);
</script>
</head>
<body><div id="out" ></div>
</body>
</html>
另外我想知道是否有一种方法可以通过查询 mysql 数据库来设置 feeds 数组的值。