答复
:使用以下格式的URL
https://api.github.com/repos/:owner/:repo/contents/:path?ref=tag/commit/branch
和
这个
Accept:application/vnd.github.v3.raw
标题集。
获取
os-lists.txt
上述示例中的文件使用:
curl -s -H "Accept:application/vnd.github.v3.raw" https://api.github.com/repos/webmin/webmin/contents/os_lists.txt
说明:
-
https://api.github.com/repos/
github API的基本URL
-
:owner/:repo/
将其替换为所有者和存储库的名称
-
:path
将其替换为存储库中文件的路径
-
?ref=
可选参数,用于选择从中获取文件的分支、提交或标记。如果未指定,则从存储库默认分支获取文件
有关更多信息,请参阅:
https://developer.github.com/v3/repos/contents/
-
接受:应用程序/vnd。github。v3。未经加工的
必须在获取原始文件时设置标头。如果没有此标头,您将获得JSON格式的文件信息:
{
"name": "os_list.txt",
"path": "os_list.txt",
"sha": "2fa32a1860063f47c9d9ddcfe73368329cef0ba1",
"size": 31563,
"url": "https://api.github.com/repos/webmin/webmin/contents/os_list.txt?ref=master",
"html_url": "https://github.com/webmin/webmin/blob/master/os_list.txt",
"git_url": "https://api.github.com/repos/webmin/webmin/git/blobs/2fa32a1860063f47c9d9ddcfe73368329cef0ba1",
"download_url": "https://raw.githubusercontent.com/webmin/webmin/master/os_list.txt",
"type": "file",
"content": "IyBQY......",
}
有关更多信息,请参阅:
https://developer.github.com/v3/
参考文献:
https://developer.github.com/v3/repos/contents/
https://developer.github.com/v3/
https://github.com/qooob/authentic-theme/pull/1083