我想知道如何使用YQL获取JSON数据。使用YQL为Facebook获取JSON数据
这是我的JSON网址:
https://www.facebook.com/feeds/page.php?id=397319800348866&format=json
我想知道如何使用YQL获取JSON数据。使用YQL为Facebook获取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"
这比你想,如果你使用jQuery.getJSON容易。
试试这个:
$.getJSON("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22your_url&format=json",
function(data) {
var id = data.query.results.div;
$('#table').append('<li>'+id.h1+'</li>');
$('#table').listview('refresh');
}
);
感谢@arttronics :) –
那我给定的网址?你可以使用我给定的网址做一个小提琴吗? – sami
@sami:** Steven Farley **已经完成了这项工作...... –
在这里http://developer.yahoo.com/yql/console/。我不知道如何使用它 – sami