Question

I have an RSS feed which I've created in Yahoo Pipes. You can view it here.

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).

Here's the code I've used:

<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>

...and here it is on an example page.

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.

How can I output a proper PubDate on Google Feed from a Yahoo Pipes RSS feed? Is this even possible?

Was it helpful?

Solution

Simply change:

thefeeds[i].pubDate

to:

thefeeds[i].publishedDate

I tested this on Google Code Playground:

  • 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);
    

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top