2017-08-25 105 views
3

爲了使用jQuery製作跨域AJAX請求,我嘗試使用YQL RSS。雅虎YQL RSS - 錯誤請求

select * from rss where url='https://www.top1000funds.com/feed/most-popular-posts/' 

我的代碼:

var feed = "https://www.top1000funds.com/feed/most-popular-posts/"; 
 
var yql = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22"+encodeURIComponent(feed)+"%22&format=json&diagnostics=true&callback=&rnd=_"+event.timeStamp; 
 
console.log(yql); 
 

 
$.getJSON(yql, function(res) { 
 
    var html = '<div class="feedListWrap">'; 
 
    if(res.query && res.query.results && res.query.results.item){ 
 
     //code goes here 
 
    } else { 
 
     html += '<div class="feedEmpty">The feed is currently not available due to server issues. Check back soon!</div>'; 
 
    } 
 
    html += '</div>'; 
 
    rssWrap.append(html); 
 
}, "jsonp");

它能正常工作,但現在我得到了錯誤的請求的問題上沒有錯誤的文字說明JSON響應:

{"query":{"count":0,"created":"2017-08-25T03:09:09Z","lang":"en","diagnostics":{"publiclyCallable":"true","url":{"execution-start-time":"0","execution-stop-time":"2","execution-time":"2","http-status-code":"400","http-status-message":"Bad Request","content":"https://www.top1000funds.com/feed/most-popular-posts/"},"user-time":"2","service-time":"2","build-version":"2.0.164"},"results":null}} 

您可以使用url查詢進行測試:link

當試圖在YQL控制檯檢查,它工作正常:

{ 
"query": { 
    "count": 10, 
    "created": "2017-08-25T02:54:38Z", 
    "lang": "en-US", 
    "diagnostics": { 
    "publiclyCallable": "true", 
    "url": { 
    "execution-start-time": "1", 
    "execution-stop-time": "8", 
    "execution-time": "7", 
    "content": "https://www.top1000funds.com/feed/most-popular-posts/" 
    }, 
    "user-time": "8", 
    "service-time": "7", 
    "build-version": "2.0.164" 
    }, 
    "results": { 
    "item": [ 
    { 
    "title": "OTPP’s private equity revolution", 
    "link": "https://www.top1000funds.com/profile/2017/08/03/otpps-private-equity-revolution/", 
    "pubDate": "Thu, 03 Aug 2017 06:39:33 +0000", 
    "creator": "Sarah Rundell", 
    "guid": { 
     "isPermaLink": "false", 
     "content": "http://www.top1000funds.com/?p=17673" 
    }, 
    "description": "<div class=\"feedThumb\"><img width=\"125\" height=\"125\" src=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-125x125.jpg\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-125x125.jpg 125w, https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-150x150.jpg 150w\" sizes=\"(max-width: 125px) 100vw, 125px\" /></div><div class=\"feedExcerpt\">A deep dive into the world-class private capital division of OTPP, led by Jane Rowe, reveals a strategy of buying large direct stakes in companies, and a commitment to innovation.</div>", 
    "encoded": "<div class=\"feedThumb\"><img width=\"125\" height=\"125\" src=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-125x125.jpg\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-125x125.jpg 125w, https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2017/08/03163918/jane-rowe_700px-150x150.jpg 150w\" sizes=\"(max-width: 125px) 100vw, 125px\" /></div><div class=\"feedExcerpt\">A deep dive into the world-class private capital division of OTPP, led by Jane Rowe, reveals a strategy of buying large direct stakes in companies, and a commitment to innovation.</div>" 
    }, 
    { 
    "title": "The value of the Canadian model", 
    "link": "https://www.top1000funds.com/analysis/2017/08/08/the-value-of-the-canadian-model/", 
    "pubDate": "Tue, 08 Aug 2017 04:53:00 +0000", 
    "creator": "AMANDA WHITE", 
    "guid": { 
     "isPermaLink": "false", 
     "content": "http://www.top1000funds.com/?p=17681" 
    }, 
    "description": "<div class=\"feedThumb\"><img width=\"125\" height=\"125\" src=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-125x125.jpg\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-125x125.jpg 125w, https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-150x150.jpg 150w\" sizes=\"(max-width: 125px) 100vw, 125px\" /></div><div class=\"feedExcerpt\">A lot has been written about the superiority of the 「Canadian model」 for managing pensions, but can a value be assigned to this organisational design structure? </div>", 
    "encoded": "<div class=\"feedThumb\"><img width=\"125\" height=\"125\" src=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-125x125.jpg\" class=\"attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" srcset=\"https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-125x125.jpg 125w, https://dmmn26wgpgtie.cloudfront.net/wp-content/uploads/2016/03/22215806/Keith-Ambachtsheer-Head_Shoulders_Jan-700x500-2016-150x150.jpg 150w\" sizes=\"(max-width: 125px) 100vw, 125px\" /></div><div class=\"feedExcerpt\">A lot has been written about the superiority of the 「Canadian model」 for managing pensions, but can a value be assigned to this organisational design structure? </div>" 
    }, 
    ... 
    ] 
    } 
} 
} 

有什麼建議嗎?

+0

不知何故,它再次正常工作了幾分鐘,然後現在它已關閉。有關於此的任何建議嗎? –

回答

0

我有完全相同的問題。我的代碼有點不同,但原理是一樣的 - 我通過YQL運行RSS源來解決跨域問題。它工作正常,直到昨天,但它現在返回相同的錯誤請求錯誤,但是,查詢我每次都在YQL控制檯中使用作品。

惟一可行的辦法我已經能夠找到的是在線程:jQuery with YQL RSS Feeds randomly returning null

這表明,它可能與超時上是不存在的YQL控制檯上的API。

如果任何人都可以證實這一點,或提供其他的可能性我也想聽聽他們。

+0

同樣的問題在這裏。我的代碼一直運行到YQL,直到昨天爲止,現在這個..希望他們能儘快修復! – MikkoS

+0

我認爲雅虎API存在問題,自從昨天以來也存在問題。 – MrSoolmaan

1

我覺得這是從雅虎YQL端的問題,而不是從使用的代碼或其他東西有關。 如果刷新查詢,他會隨機加載錯誤或罰款。

我覺得我們沒有什麼(用戶)可以做些什麼。 雅虎需要解決這個問題...

0

當YQL控制檯上的嘗試,它緩存的結果,我相信。如果你進入調試模式,它不會使用欺騙結果,所以你會看到更好的任何問題。

0

從我的身邊,一切運作良好,因爲2天。