jimbojsb / github-repo-events
解析 Github Repo Events API 的独立客户端
v0.1.2
2017-02-17 17:15 UTC
Requires
- php: >= 5.5
- resty/resty: ^0.6.0
This package is auto-updated.
Last update: 2024-09-18 05:10:36 UTC
README
此库允许您轮询 Github 事件 API,而不是使用 Webhook。
用法
公共仓库的基本用法
$eventsStream = new GithubRepoEvents\RepsitoryEventStream("user/repo"); foreach ($eventsStream as $event) { // do stuff with events }
添加 API 密钥以增加配额或访问私有仓库
$eventsStream = new GithubRepoEvents\RepsitoryEventStream("user/repo", "githubApiKey"); foreach ($eventsStream as $event) { // do stuff with events }
使用 ETags 以避免配额超限
// costs from quota $eventsStream = new GithubRepoEvents\RepsitoryEventStream("user/repo", "githubApiKey"); foreach ($eventsStream as $event) { // do stuff with events } $etag = $eventStream->getEtag(); // does not cost from quota, assuming the stream has no new events $eventsStream = new GithubRepoEvents\RepsitoryEventStream("user/repo", "githubApiKey"); $eventStream->setEtag($etag); foreach ($eventsStream as $event) { // do stuff with events }