我已经使用这段代码从GitHub API中获取数据
var name;
var description;
var html_url;
var username = "PirateStef";
var updated_at;
var language;
var repo;
var urlGitHub = 'https://api.github.com/users/'+username+'/repos?sort=created';
$.getJSON(urlGitHub, function(json){
repositories = json;
outputGitHubContent(); // GitHub Content
});
function outputGitHubContent() {
$.each(repositories, function(index){
name = "<div class='name'>" + repositories[index].name + "</div>";
description = "<div class='description'>" + repositories[index].description + "</div>";
updated_at = "<div class='updated_at'>" + repositories[index].updated_at.substring(0,10) + "</div>";
html_url = "<a class='html_url' target='_blank' href='" + repositories[index].html_url + "'>";
language = "<div class='language'>" + repositories[index].language + "</div>";
repo = "<div class='repo'>" + html_url + "<div>" + name + language + "</div>" + description + updated_at + "</a> </div>";
console.log(repositories[index].owner.login);
$("#github").append(repo);
});
};
这是Github API网址
https://api.github.com/users/PirateStef/repos?sort=updated
我已经尝试构建一个函数来获取运球数据。使用下面的api.dribbble网址。
http://api.dribbble.com/players/PirateStef/shots/
我无法从每个对象中获取“标题”。
无效的运球代码
var urlDribbble = 'http://api.dribbble.com/players/'+username+'/shots/';
var shot;
$.getJSON(urlDribbble, function(json){
shots = json;
outputDribbbleContent(); // Dribbble Content
});
function outputDribbbleContent() {
$.each(shots, function(index){
console.log(shots[index].title);
});
};
让我5x undefined
console.log(shots[index]);
让我这个
[
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
,
Object
]
答案 0 :(得分:2)
我知道答案有点晚了,但我最近在运球的某些部分工作并了解这些:
'https://api.dribbble.com/v1/users/'+user_id+'/buckets?access_token='+dribbble_access_token
这将为用户存储区数据提供:
created_at
说明
ID
命名
shots_count
的updated_at
现在可以使用以下镜头:
'https://api.dribbble.com/v1/buckets/'+bucket_id+'/shots?access_token='+dribbble_access_token
或
'https://api.dribbble.com/v1/users/'+user_id+'/shots?access_token='+dribbble_access_token
这将提供12(默认)拍摄数据和所有可能的分辨率图像。 虽然我仍然在寻找任何参数来管理限制,即默认为12。
好的,我也得到了设定限制的解决方案。要传递的参数是
per_page
这可以接收任何数值。所以我的最终网址是:
'https://api.dribbble.com/v1/users/'+user_id+'/shots?per_page='+limit+'&access_token='+dribbble_access_token
我在Joomla的一个漂亮的Multi social tabs模块中使用过它 按Webkul,按照link进行查看 只需检查那里的运球标签
答案 1 :(得分:0)
我已经使用了jribbble插件,这样我就不必使用dribbble来注册应用程序。