2013-10-14 26 views
3

我有一個我在Yahoo Pipes中創建的RSS源。你可以view it hereYahoo Pipes RSS pubDate在通過Google Feeds API查看時顯示爲「undefined」

但是,通過Google Feed的API查看發佈時,pubDate會以未定義的形式出現(爲了避免疑問,我也嘗試使用PubDate案例進行格式化)。

下面是我使用的代碼:

<div class="clear" id="feed"> 
    &nbsp;</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> 

...這裏是上example page

我已經做了一些關於這方面的搜索,並發現雅虎管道輸出PubDate的方式似乎存在一些小問題。我試着按照Can't get pubDate to output in Yahoo! Pipes?(產生的管道是here)這個問題中的說明操作,但似乎沒有任何區別。

如何從Yahoo Pipes RSS提要在Google Feed上輸出正確的PubDate?這甚至有可能嗎?

回答

2

簡單的改變:

thefeeds[i].pubDate 

到:

  • https://code.google.com/apis/ajax/playground/#load_feed
  • OnLoad,昌:

    thefeeds[i].publishedDate 
    
    我測試了這個在谷歌代碼遊樂場

    E中的URL到您的雅虎管道鏈接

  • 在主迴路feedLoaded,編輯中間環節:

    div.appendChild(document.createTextNode(entry.title)); 
    div.appendChild(document.createTextNode(entry.publishedDate)); 
    console.log(entry); 
    

具體在JavaScript控制檯中可以看到entry對象具有publishedDate屬性而不是pubDate

它在操場上工作,它也應該在你的網站上工作,我希望。

+0

它的確如此!歡呼。 – BFWebAdmin