问题描述
我有一个我在Yahoo Pipes中创建的RSS源。您可以。
I have an RSS feed which I've created in Yahoo Pipes. You can view it here.
然而,当通过Google Feed的API查看时,pubDate将显示为未定义(为避免疑问,我还尝试使用PubDate格式化格式)。
When viewing that through Google Feed's API, however, the pubDate is coming up as undefined (for avoidance of doubt, I've also tried formatting that with the case PubDate).
这是我用过的代码:
<div class="clear" id="feed">
</div>
<script type="text/javascript">
var feedcontainer=document.getElementById("feed")
var feedurl="http://pipes.yahoo.com/pipes/pipe.run?_id=f0eb054e3a4f8acff6d4fc28eda5ae32&_render=rss"
var feedlimit=5
var rssoutput="<h3>Business and Tax News</h3><ul>"
function rssfeedsetup(){
var feedpointer=new google.feeds.Feed(feedurl)
feedpointer.setNumEntries(feedlimit)
feedpointer.load(displayfeed)
}
function displayfeed(result){
if (!result.error){
var thefeeds=result.feed.entries
for (var i=0; i<thefeeds.length; i++)
rssoutput+="<li><a href='" + thefeeds[i].link + "'>" + thefeeds[i].title + " (" + thefeeds[i].pubDate +")</a></li>"
rssoutput+="</ul>"
feedcontainer.innerHTML=rssoutput
}
else
alert("Error fetching feeds!")
}
window.onload=function(){
rssfeedsetup()
}
</script>
......这里是。
...and here it is on an example page.
我做过一些关于此的谷歌搜索,并发现雅虎管道输出PubDate的方式似乎有一点记录的问题。我已经尝试按照(生成的管道是),但它似乎没有任何区别。
I've done some Googling about on this, and discovered that there appears to be a little documented problem with the way that Yahoo Pipes outputs PubDate. I've tried following the instructions in the question Can't get pubDate to output in Yahoo! Pipes? (the resulting pipe is here), but it doesn't seem to make any difference.
如何从Yahoo Pipes RSS提要在Google Feed上输出正确的PubDate?这甚至可能吗?
How can I output a proper PubDate on Google Feed from a Yahoo Pipes RSS feed? Is this even possible?
推荐答案
只需更改:
thefeeds[i].pubDate
to:
thefeeds[i].publishedDate
我在 Google Code Playground上测试了这个:
- 在
OnLoad
中,将网址更改为Yahoo Pipes链接 -
在<$ c $的主循环中c> feedLoaded ,编辑中间部分:
- https://code.google.com/apis/ajax/playground/#load_feed
- In
OnLoad
, change the URL to your Yahoo Pipes link In the main loop in
feedLoaded
, edit the middle part to:
div.appendChild(document.createTextNode(entry.title));
div.appendChild(document.createTextNode(entry.publishedDate));
console.log(entry);
特别是在JavaScript控制台中,您可以看到条目
对象有一个 publishedDate
属性,而不是 pubDate
。
Specifically in the JavaScript console you can see the entry
object has a publishedDate
property instead of pubDate
.
它可以在操场上运行,它也可以在你的网站上运行,我希望。
It it works on the playground, it should work on your site too, I hope.
这篇关于Yahoo Pipes RSS pubDate显示为“未定义”通过Google Feeds API查看时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!