jquery - 使用 YQL for Facebook 获取 JSON 数据

标签 jquery ajax json yql

我想知道如何使用 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/

相关文章:

jquery - HTML 列表 - 仅将 addClass() 应用于第一级 LI 元素(不是内部元素)

javascript - 根据下拉列表的值隐藏和显示一行表 - jquery

php - 如何使用ajax将产品添加到购物车?

javascript - 根据唯一ID合并geojson

javascript - 在jsp中读取一个json对象

javascript - 如何在JSON数组中显示单个值

jQuery - 删除特定子元素之前的所有子元素

php - Javascript 自动提交表单

javascript - 按钮值传递到模式

javascript - 迭代 JSON 以创建 innerHTML 链接