取使用YQL对于Facebook JSON数据 [英] Fetch JSON data using YQL for Facebook

查看:125
本文介绍了取使用YQL对于Facebook JSON数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用,以获取JSON数据 YQL

这是我的JSON网址:

  https://www.facebook.com/feeds/page.php?id=397319800348866&format=json
 

解决方案

继承人使用jQuery一个简单的例子,它可能会帮助你。

  $(函数(){
    $阿贾克斯({
        网址:http://query.yahooapis.com/v1/public/yql
        数据类型:JSONP
        成功:功能(数据){
            执行console.log(data.query.results.json);
            $每个(data.query.results.json.entries,功能(I,V){
                //console.log(data.query.results.json.entries[i]);
                $('#项目)追加(data.query.results.json.entries [I] .title伪+'< BR />');
            });
        }, 数据: {
            问:从JSON其中,url =https://www.facebook.com/feeds/page.php?id=397319800348866&format=jsonSELECT *,
            格式为:JSON
        }
    });
});
 

在上述网址我能得到以下结果的console.log:

 条目:数组[29]
图标:http://www.facebook.com/favicon.ico
链接:http://www.facebook.com/
自我:https://www.facebook.com/feeds/page.php?id=397319800348866&format=json
标题:实干家公司的Facebook墙
更新:2012-12-19T01:08:44-08:00
 

,以供参考工作例如: http://jsfiddle.net/DtNxb/1/

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/

这篇关于取使用YQL对于Facebook JSON数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆