从 GitHub 获取数据是可能的,从 dribbble 获取数据不起作用

问题描述 投票:0回答:2

我使用这段代码从 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 url。

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

让我 5 倍未定义

console.log(shots[index]);

让我明白这个

[
Object
, 
Object
, 
Object
, 
Object
, 
Object
, 
Object
, 
Object
, 
Object
, 
Object
, 
Object
, 
Object
, 
Object
, 
Object
]
jquery json github dribbble-api
2个回答
1
投票

我知道现在回答有点晚了,但我最近在研究运球的某些部分并开始了解这些:

'https://api.dribbble.com/v1/users/'+user_id+'/buckets?access_token='+dribbble_access_token

这将提供用户存储桶数据:

创建于
描述
编号
名字
镜头数
更新于

现在要拍摄照片,您可以使用:

'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。

好的,我也找到了设置限制的解决方案。要传递的参数是

每页

它可以接收任何数值。所以我的最终网址是:

'https://api.dribbble.com/v1/users/'+user_id+'/shots?per_page='+limit+'&access_token='+dribbble_access_token

我已经在 Joomla 的一个漂亮的多社交标签模块中使用了它 作者:Webkul,请点击 link 查看它 只需检查那里的运球选项卡


0
投票

我使用了 jribbble 插件,这样我就不用再用 dribbble 注册应用了。

© www.soinside.com 2019 - 2024. All rights reserved.