我可以看到特定用户的所有事件,例如这里是我的:
https://api.github.com/users/arasbm/events
但我只对特定类型的事件感兴趣:
"type": "PushEvent",
如何在不必处理所有事件列表的情况下获取这些数据(这可能很慢)。我正在尝试这样做,因为我想获得我所有已合并的 PR 的列表。如果你能给我 curl 命令,那就太棒了。我在 github api 文档中的任何地方都找不到这个。
最佳答案
正如“How do I get notifications for commits to the framework? ”中所确认的,您必须过滤 JSON /users/username/events
回复。
$.each(data.data, function(key, val) {
if (val.type == "PushEvent") {
$.each(val.payload.commits, function(key2, val2) {
list.append('<li id="' + val2.sha + '"><a href="https://github.com/UnionOfRAD/lithium/commit/' + val2.sha + '">' + val2.message + '</a> [' + val.actor.login + ' @ ' + val.created_at + ']</li>');
});
}
});
或者:
您可以监控提交 RSS 提要(如“Setting up an Github Commit RSS feed ”:
https://github.com/user/repo/commits/master.atom
# more general url:
https://github.com/user/repo/commits/branch_name.atom?login=login&token=token
但这将适用于一个用户的一个存储库,而不是所有用户存储库。
关于rest - 如何为用户获取所有 github `PushEvents` 的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18733424/