我正在尝试从 https://github.com/notifications 上显示的 GitHub 中获取相同的信息页。不幸的是,标准notifications API真的不符合那个观点。
如果我从该 API 收到通知(即使使用 participating=false
),我也看不到网站上可见的所有项目。另一方面,API 似乎基于 last_read_at
想法,我在网站上看到的东西不会从通知列表中自动消失。
有没有办法(不抓取网站)获得相同的 /notifications
看法?
最佳答案
因此 GitHub 的 API 支持对返回列表的请求进行分页,因此该 API 将默认每页返回 30 个通知。我的建议是将默认大小设置为 100,然后从第 1 页开始并调用下一页,直到没有结果,例如:
<https://api.github.com/notifications?page=1&per_page=100>; rel="next"
<https://api.github.com/notifications?page=2&per_page=100>; rel="next"
...and so on till you get an empty list then you stop
rel="next"是一个链接头,解释如下:https://developer.github.com/v3/#pagination
希望这可以帮助
关于github - 如何获取与通知站点匹配的 GitHub API 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42902762/