您应该能够通过 GitHub Events API 访问此信息。
- 句法:
GET /repos/:owner/:repo/events
- 例子:
https://api.github.com/users/libgit2/events
这将返回一个 JSON 事件数组。为了发现谁推送到此存储库,您必须过滤这些事件并仅检查那些type
属性为 equals的事件"WatchEvent"
。该actor
属性将包含有关推送器的详细信息。
下面是这样一个示例PushEvent
{
id:"1842109394",
type:"PushEvent",
actor:{
id:39902,
login:"ben",
gravatar_id:"0d410939c9e80980cf0430772567dfb4",
url:"https://api.github.com/users/ben",
avatar_url:"https://2.gravatar.com/avatar/0d410939c9e80980cf0430772567dfb4?d=https%3A%2F%2Fa248.e.akamai.net%2Fassets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png"
},
repo:{
id:901662,
name:"libgit2/libgit2",
url:"https://api.github.com/repos/libgit2/libgit2"
},
payload:{
push_id:235346159,
size:1,
distinct_size:1,
ref:"refs/heads/redir-refactor",
head:"b59344bf83049a5639c32ab52efceea2eec9484b",
before:"256961e45d574ace62a7a7d13b697aa05e8a9466",
commits:[
{
sha:"b59344bf83049a5639c32ab52efceea2eec9484b",
author:{
email:"bs@github.com",
name:"Ben Straub"
},
message:"Tighten up url-connection utility",
distinct:true,
url:"https://api.github.com/repos/libgit2/libgit2/commits/b59344bf83049a5639c32ab52efceea2eec9484b"
}
]
},
public:true,
created_at:"2013-09-26T23:56:59Z",
org:{
id:394745,
login:"libgit2",
gravatar_id:"1c56acccc41c591705dc92da5f6ab603",
url:"https://api.github.com/orgs/libgit2",
avatar_url:"https://1.gravatar.com/avatar/1c56acccc41c591705dc92da5f6ab603?d=https%3A%2F%2Fa248.e.akamai.net%2Fassets.github.com%2Fimages%2Fgravatars%2Fgravatar-org-420.png"
}
}