使用AJAX加载RSS提要:Google Feed API的替代方案?

我一直在使用Google Feed API加载RSS Feed,但看起来谷歌已经关闭了API。 例如,当我尝试在http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&q=http%3A%2F%2Frss.nytimes.com%2Fservices%2Fxml%2Frss%2Fnyt%2FHomePage.xml上加载纽约时报RSS源时http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=1000&q=http%3A%2F%2Frss.nytimes.com%2Fservices%2Fxml%2Frss%2Fnyt%2FHomePage.xml ,我收到此回复:

 {"responseData": null, "responseDetails": "This API is no longer available.", "responseStatus": 403} 

有没有可行的替代方案?

使用Yahoo的YQL API :

 select * from xml where url = 'https://news.ycombinator.com/rss' 

您可以通过向url添加callback参数来请求JSONP Feed

 https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%20%3D%20'https%3A%2F%2Fnews.ycombinator.com%2Frss'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=mycallback 

弃用

我的 插件 , $ .jQRSS使用Google Feed ,似乎工作得很好,给出你的确切的RSS链接:

 var rss = 'http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml'; $.jQRSS(rss, { count: 8 }, function (feed, entries) { console.log([feed, entries]); $.each(entries, function(i) { if (this['content']) { var fieldset = $('
', { title: this.contentSnippet }).appendTo('body'), legend = $('').appendTo(fieldset), $link = $('', { href: this.link, html: this.title, target: '_blank' }).appendTo(legend), $date = $('
', { html: this.publishedDate }).appendTo(fieldset), $content = $('
', { html: this.content }).appendTo(fieldset); $content.find('br').remove(); } }); });
 fieldset > h5 { float: right; margin-top: 0; } 
   

Tony使用YQL的解决方案的一个补充 – 我需要将回调值更改为JSON_CALLBACK以正确解析响应:

 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%20%3D%20\'' + encodeURIComponent(url) + '\'&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=JSON_CALLBACK' 

您可以使用脚本feedburner:

所有信息:

https://support.google.com/feedburner/answer/78991?hl=en

您可以使用PHP获取要显示的任何RSS源的副本,然后使用客户端JavaScript显示结果。 主要优点是您不受每日请求限制,大多数免费RSS API服务或可靠性问题。

http://www.javascriptkit.com/dhtmltutors/ajaxticker/index.shtml