1
我可以通過GitHub API得到公共事件的組織的名單: GET /orgs/:org/events
如何通過事件ID獲取GitHub事件有效載荷?
如何獲得一個事件的有效載荷(如PushEvent)知道它的ID?
我可以通過GitHub API得到公共事件的組織的名單: GET /orgs/:org/events
如何通過事件ID獲取GitHub事件有效載荷?
如何獲得一個事件的有效載荷(如PushEvent)知道它的ID?
GitHub API無法通過其ID來檢索特定事件。
每個事件都有一個。例如
{
"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": "[email protected]",
"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": "[email protected]",
"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
},
哪個是來自事件的有效負載。這是獲取有效負載(來自列表事件)的唯一方法。