I want to know how to fetch the JSON data using YQL.
This is my JSON URL:
https://www.facebook.com/feeds/page.php?id=397319800348866&format=json
I want to know how to fetch the JSON data using YQL.
This is my JSON URL:
https://www.facebook.com/feeds/page.php?id=397319800348866&format=json
Heres a quick example using jQuery, it might help you out
$(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"
}
});
});
Inside the console.log with the above url I was able to get back the following results:
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"
Working example for reference: http://jsfiddle.net/DtNxb/1/
It's easier than you think if you use jQuery.getJSON.
Try this:
$.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');
}
);