Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetch JSON data using YQL for Facebook [closed]

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
like image 586
sami Avatar asked Aug 22 '26 18:08

sami


2 Answers

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/

like image 116
PhearOfRayne Avatar answered Aug 25 '26 07:08

PhearOfRayne


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');
          }
);

A simple demo here

like image 40
palaѕн Avatar answered Aug 25 '26 08:08

palaѕн



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!