Google Feed API:"不支持Feed网址中指定的端口。"

时间:2012-05-08 18:14:43

标签: ajax atom-feed google-feed-api

我正在尝试实施Google Feed API以从服务器访问ATOM Feed,然后在移动网络应用上显示数据。我收到错误“不支持在Feed网址中指定的端口。”有什么想法或建议吗?

   // Google Feed API
//Our callback function, for when a feed is loaded.
function feedLoaded(result) {
  if (!result.error) {
      console.log("no error in loading feed");
    // Grab the container we will put the results into
    var container = document.getElementById("page_contents");
    container.innerHTML = '';

    // Loop through the feeds, putting the titles onto the page.
    // Check out the result object for a list of properties returned in each entry.
    // http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON
    for (var i = 0; i < result.feed.entries.length; i++) {
      var entry = result.feed.entries[i];
      var div = document.createElement("div");
      div.appendChild(document.createTextNode(entry.content));
      container.appendChild(div);
    }

    console.log(result.feed.entries.length);
  } else {
      var container = document.getElementById("page_contents");
      container.innerHTML = '';

      var div = document.createElement("div");
      div.appendChild(document.createTextNode(result.error.message));
      container.appendChild(div);

      alert(result.error.message);

  }
}

function OnLoad() {
  // Create a feed instance that will grab Digg's feed.
    var feed = new google.feeds.Feed("http://localhost:8082/frevvo/web/tn/billy.com/api/apps");
    //var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
  if (!feed) {
      alert("feed object not created");
  } 
  console.log("loading feed");
  // Calling load sends the request off.  It requires a callback function.
  feed.load(feedLoaded);
}

1 个答案:

答案 0 :(得分:0)

您似乎设置端口的唯一位置是您指定网址http://localhost:8082/frevvo/web/tn/billy.com/api/apps的位置。

将该URL更改为某个不使用非标准端口的RSS源,此错误几乎肯定会消失。

为了进行测试,我会经常访问新闻网站并获取他们的RSS提要网址,例如http://rss.cnn.com/rss/cnn_topstories.rss