使用GitHub list-issues-for-repository API [英] Using GitHub list-issues-for-a-repository API

查看:136
本文介绍了使用GitHub list-issues-for-repository API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您转到GitHub的Issues下时,它将所有未解决的问题作为HTML页面拉出.我们想要实现一个仪表板,以显示存储库中的所有问题,并按标签分组,包括那些未正确标记的问题.

When you go to GitHub, under Issues, it pulls up all the open issues as an HTML page. We'd like to implement a dashboard showing all the issues in a repository, grouped by labels, including those issues which are not correctly labelled.

这是相应的 list-issues-for-一个存储库API .

虽然我最初使用jQuery和Javascript,但现在使用PHP进行概念验证,因为其内置的会话处理功能使我可以使用同一页面登录,让GitHub进行身份验证和验证.回调,然后继续.但这对我来说没关系,任何语言都可以.

While I was initially using jQuery and Javascript, am now using PHP for a proof-of-concept because its built-in session handling lets me use the same page to login, have GitHub authenticate & callback, and continue. But it doesn't matter to me, any language is okay.

我设法通过OAUTH2访问GitHub API,但是当我通过https://api.github.com/orgs/{org}/repos获取存储库列表时,它以一个空数组的形式出现.

I've managed to get access to the GitHub API via OAUTH2, but when I get the list of repositories via https://api.github.com/orgs/{org}/repos it comes up as an empty array.

因为/orgs/{org}/repos API返回一个空数组,所以相应的/repos/{org}/{repo}/issues API当然会返回一个错误.

Because the /orgs/{org}/repos API returns an empty array, of course the corresponding /repos/{org}/{repo}/issues API will return an error.

编辑:有关解决方案,请参见此后续操作!很高兴我终于可以正常工作了!

Edit: See this followup for a solution! Glad I finally got it working!

推荐答案

这是一个Rest API.您需要使用Http请求来调用某些终结点. 我不知道您要使用哪种语言,因此我无法为您提供实现此目标的良好示例. 如果您尚不知道要使用哪种语言,请使用 postman 创建对github API的REST API调用.

It is a rest API. You need to call some endpoints using an Http request. I don't know what language you are trying to use so I can't give you a good example on how to acheive this. If you don't know which language to use yet, use postman to create REST API call to the github API.

假设您想解决 Microsoft的打字稿存储库的问题,您需要将其称为API端点:

Let's say you want to retreive the issues of the microsoft's typescript repo, You would need to call this API endpoint :

https://api.github.com/repos/microsoft/typescript/issues

在此请注意,我已将文档的:owner:repo值替换为我要获取的文档的值.

Notice here that i have replace the :owner and :repo value of documentation for the one i'm trying to get.

然后,您可以将一些参数传递给调用以过滤数据,例如API标签.

You can then pass some parameters to the call to filter your data, for example, the API label.

https://api.github.com/repos/microsoft/typescript/issues?labels=API

这只会返回标记为API的问题.

This will only return issues that are labelled as API.

这是如何使用API​​的基础.

This is the basics of how to use an API.

这篇关于使用GitHub list-issues-for-repository API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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