如何在PHP中从github url获取特定的存储库信息


How to get specific repository info from github url in PHP?

我想使用curl获取特定存储库的信息。

假设我的GitHub repo url如下:

https://github.com/githubexample/Example-Repository

现在,当我将这个url放入输入表单并提交时,它将显示这个存储库的标题和描述。

我该怎么做?

看来您可能对这个链接感兴趣。

https://developer.github.com/v3/repos/得到

使用curl可以向

发送GET请求

GET /repos/:username/:repo

这正是你要找的。

示例:curl -i https://api.github.com/repos/octocat/Hello-World

这将返回一个json文档,包括"name"answers"description"。

edit:添加了更好的信息和示例。