2012-05-08 64 views
0

我試圖實現Google Feed API從服務器訪問ATOM訂閱源,然後在移動Web應用程序上顯示數據。我收到錯誤「Feed URL中指定的端口不受支持。」任何想法或建議?Google Feed API:「Feed URL中指定的端口不受支持。」

// 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); 
} 

回答

0

您似乎在設置端口的唯一地方是指定URL http://localhost:8082/frevvo/web/tn/billy.com/api/apps

將該URL更改爲某個不使用非標準端口的RSS源,該錯誤幾乎肯定會消失。

爲了測試,我會經常前往新聞網站並抓取他們的RSS提要URL,例如http://rss.cnn.com/rss/cnn_topstories.rss