ILy*_*Lya 106 javascript testing treeview json
我正在开发一个JavaScript动态加载的树视图用户控件.我想用真实世界的数据进行测试.
有没有人知道任何提供JSON格式的分层数据访问API的公共服务?
Ale*_*ray 61
Twitter有一个返回JSON 的公共API,例如 -
一个GET请求:
https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=mralexgray&count=1,
编辑: 由于Twitter限制他们的API有OAUTH要求删除...
{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}
Run Code Online (Sandbox Code Playgroud)
用一个简单的Github API示例替换它- 它返回一个树,在本例中是我的存储库......
我不会包含输出,因为它很长..(一次返回30个回购)...但这里证明它是树形的.

Bra*_*lio 10
从Flickr找到一个不需要注册/ api的.
基本样本,小提琴:http://jsfiddle.net/Braulio/vDr36/
更多信息:发布
粘贴样品
HTML
<div id="images">
</div>
Run Code Online (Sandbox Code Playgroud)
使用Javascript
// Querystring, "tags" search term, comma delimited
var query = "http://www.flickr.com/services/feeds/photos_public.gne?tags=soccer&format=json&jsoncallback=?";
// This function is called once the call is satisfied
// http://stackoverflow.com/questions/13854250/understanding-cross-domain-xhr-and-xml-data
var mycallback = function (data) {
// Start putting together the HTML string
var htmlString = "";
// Now start cycling through our array of Flickr photo details
$.each(data.items, function(i,item){
// I only want the ickle square thumbnails
var sourceSquare = (item.media.m).replace("_m.jpg", "_s.jpg");
// Here's where we piece together the HTML
htmlString += '<li><a href="' + item.link + '" target="_blank">';
htmlString += '<img title="' + item.title + '" src="' + sourceSquare;
htmlString += '" alt="'; htmlString += item.title + '" />';
htmlString += '</a></li>';
});
// Pop our HTML in the #images DIV
$('#images').html(htmlString);
};
// Ajax call to retrieve data
$.getJSON(query, mycallback);
Run Code Online (Sandbox Code Playgroud)
另一个非常有趣的是星球大战休息API:
| 归档时间: |
|
| 查看次数: |
130606 次 |
| 最近记录: |