2
我正在嘗試編寫一個程序,它以用戶名作爲輸入,並將用戶的Pinterest RSS源作爲JSON結構返回。這是我到目前爲止:如何將跨域Pinterest RSS源轉換爲JSON
var input = prompt("Please enter a username: ");
$(document).ready(function() {
$.ajax({
type: 'GET',
url: 'http://www.pinterest.com/'+input+'/feed.rss',
dataType: 'jsonp',
error: function(data) {
console.log('error', data);
},
success: function(data) {
console.log('success', data);
},
complete: function() {
console.log('done');
}
});
});
最初,我嘗試使用JSON,但遇到了跨域問題。當我使用JSONP時,它以XML格式返回數據。我試圖將XML轉換爲JSON,但一直不成功。我的思想是否正確,還是應該採用完全不同的方法?感謝您的時間。
使用演示,它似乎只是重新創建相同的pinterest飼料。從那裏,我將能夠使用getJSON將其登錄到控制檯?我不確定它現在是否是當地最重要的飼料。 – inthedark72
這是我在谷歌上找到的一個例子。你必須適應你的需求。 Google Feed已經將RSS feed轉換爲JSON - 只需閱讀以下文檔:https://developers.google.com/feed/v1/devguide – Roni
@ user2731392 - 如果您想要一個示例,它如何工作:http://jsfiddle.net/mvark/Bg6FZ/ – Roni