我可以通过GitHub API获取组织的公开活动列表:
GET /orgs/:org/events
如何获取事件有效负载(如PushEvent)知道其ID?
答案 0 :(得分:1)
GitHub API无法通过其ID检索特定事件。
每个事件都有一个payload
。例如
{
"actor": {
"avatar_url": "https://avatars.githubusercontent.com/u/240830?",
"display_login": "sigmavirus24",
"gravatar_id": "",
"id": 240830,
"login": "sigmavirus24",
"url": "https://api.github.com/users/sigmavirus24"
},
"created_at": "2017-01-27T23:50:12Z",
"id": "5227100855",
"org": {
"avatar_url": "https://avatars.githubusercontent.com/u/1782156?",
"gravatar_id": "",
"id": 1782156,
"login": "github3py",
"url": "https://api.github.com/orgs/github3py"
},
"payload": {
"before": "7d52c200d80d86f70fbda3e9ebf48060867f9f65",
"commits": [
{
"author": {
"email": "sigmavirus24@users.noreply.github.com",
"name": "Ian Cordasco"
},
"distinct": true,
"message": "Create test.txt",
"sha": "a623ca5974523ec35fd83909dd99b220e498ef58",
"url": "https://api.github.com/repos/github3py/delete_contents/commits/a623ca5974523ec35fd83909dd99b220e498ef58"
}
],
"distinct_size": 1,
"head": "a623ca5974523ec35fd83909dd99b220e498ef58",
"push_id": 1525269783,
"ref": "refs/heads/master",
"size": 1
},
"public": true,
"repo": {
"id": 50486230,
"name": "github3py/delete_contents",
"url": "https://api.github.com/repos/github3py/delete_contents"
},
"type": "PushEvent"
}
执行GET /orgs/github3py/events
后是否来自列表中的事件。如果仔细观察,你会看到
"payload": {
"before": "7d52c200d80d86f70fbda3e9ebf48060867f9f65",
"commits": [
{
"author": {
"email": "sigmavirus24@users.noreply.github.com",
"name": "Ian Cordasco"
},
"distinct": true,
"message": "Create test.txt",
"sha": "a623ca5974523ec35fd83909dd99b220e498ef58",
"url": "https://api.github.com/repos/github3py/delete_contents/commits/a623ca5974523ec35fd83909dd99b220e498ef58"
}
],
"distinct_size": 1,
"head": "a623ca5974523ec35fd83909dd99b220e498ef58",
"push_id": 1525269783,
"ref": "refs/heads/master",
"size": 1
},
这是事件的有效负载。这是获得有效负载的唯一方法(来自列出事件)。