Github API列出所有存储库和回购的内容 [英] Github API List all repositories and repo's content

查看:103
本文介绍了Github API列出所有存储库和回购的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我只想在外部网站上显示我的github存储库及其内容,我该如何去做这件事?如果没有将我指向正确的方向,是否有任何源代码可以提供给我?我是一个初学者,所以任何帮助都是值得赞赏的。谢谢大家。
浏览一下他们的网站



我浏览了相关链接,但仍然无法知道我会如何实现这一目标。



-Github列出所有Repo's



-Github列出所有回购内容

解决方案

以前的所有答案都很棒。但如果你正在寻找一个快速和肮脏的例子如何获得公开可用的回购清单,然后检查我的 jsfiddle。



它使用这个ajax调用来列出所有用户的公共回购:



<$点击(函数(){
$ .ajax({
类型:GET,
url:pre $> $(#btn_get_repos)。 https://api.github.com/users/google/repos,
dataType:json,
success:function(result){
for(var i in result){
$(#repo_list)。append(
< li>< a href ='+ result [i] .html_url +''target ='_ blank'>+
result [i] .name +< / a>< / li>
);
console.log(i:+ i);
}
console.log(result);
$(#repo_count)。append(Total Repos:+ result.length);
}
});
});

查看返回什么样的数据只需在点击按钮后检查控制台,或者您可以安装Google Chromes JSONView扩展,然后访问ajax请求正在制作的url,即 https://api.github .com / users / google / repos

If I was to go about displaying just MY github repositories and their contents on an external website how would i go about doing this? Are there any source code's you can provide me with, if not point me in the right direction? I'm quite a beginner to programming so any help is appreciated. Thank you everyone. Taking a glance at their website

I glanced over relevant links- but still have no clue how I would accomplish this.

-Github List all Repo's

-Github List all Repo content

解决方案

all of the previous answers are great. however if you are looking for a quick and dirty example of how to get a list of publicly available repos then check out my jsfiddle.

which uses this ajax call to list all of a users public repos:

$("#btn_get_repos").click(function() {
    $.ajax({
        type: "GET",
        url: "https://api.github.com/users/google/repos",
        dataType: "json",
        success: function(result) {
            for(var i in result ) {
                $("#repo_list").append(
                    "<li><a href='" + result[i].html_url + "' target='_blank'>" +
                    result[i].name + "</a></li>"
                );
                console.log("i: " + i);
            }
            console.log(result);
            $("#repo_count").append("Total Repos: " + result.length);
        }
    });
});

to see what kind of data is returned just check the console after clicking the button or you can install Google Chromes JSONView extension and then just visit the url that the ajax request is making i.e. https://api.github.com/users/google/repos

这篇关于Github API列出所有存储库和回购的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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