我想知道如何使用 YQL 获取 JSON 数据.
这是我的 JSON 网址:
https://www.facebook.com/feeds/page.php?id=397319800348866&format=json
最佳答案
这是一个使用 jQuery 的快速示例,它可能会对您有所帮助
$(function () {
$.ajax({
url: "http://query.yahooapis.com/v1/public/yql",
dataType: "jsonp",
success: function (data) {
console.log(data.query.results.json);
$.each(data.query.results.json.entries, function (i, v) {
//console.log(data.query.results.json.entries[i]);
$('#entries').append(data.query.results.json.entries[i].title + '<br />');
});
}, data: {
q: 'select * from json where url="https://www.facebook.com/feeds/page.php?id=397319800348866&format=json"',
format: "json"
}
});
});
在具有上述网址的 console.log 中,我能够得到以下结果:
entries: Array[29]
icon: "http://www.facebook.com/favicon.ico"
link: "http://www.facebook.com/"
self: "https://www.facebook.com/feeds/page.php?id=397319800348866&format=json"
title: "Doers Inc's Facebook Wall"
updated: "2012-12-19T01:08:44-08:00"
引用工作示例:http://jsfiddle.net/DtNxb/1/
关于jquery - 使用 YQL for Facebook 获取 JSON 数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13948201/