php github api
v3.16.0
GitHub API 的简单面向对象包装器,用 PHP 编写。
使用 GitHub API v3 并支持 GitHub API v4。对象 API (v3) 与 RESTful API 非常相似。
通过作曲家。
此命令将使您能够快速启动并运行 Guzzle HTTP 客户端。
composer require knplabs/github-api:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0
在 HTTPlug 的帮助下,我们与任何 HTTP 消息传递客户端解耦。
composer require knplabs/github-api:^3.0 symfony/http-client nyholm/psr7
使用此 HTTP 客户端设置 Github 客户端
use Github Client ;
use Symfony Component HttpClient HttplugClient ;
$ client = Client:: createWithHttpClient ( new HttplugClient ());
在我们的文档中阅读有关使用不同客户端的更多信息。
为了将该库集成到 Laravel 中,Graham Campbell 创建了 graham-campbell/github。请参阅安装说明以开始使用 Laravel。
php-github-api
客户端的基本使用 <?php
// This file is generated by Composer
require_once __DIR__ . ' /vendor/autoload.php ' ;
$ client = new Github Client ();
$ repositories = $ client -> api ( ' user ' )-> repositories ( ' ornicar ' );
从$client
对象,您可以访问所有可用的 GitHub api 端点。
此示例使用 PSR6 缓存池 redis-adapter。请参阅 http://www.php-cache.com/ 了解替代方案。
<?php
// This file is generated by Composer
require_once __DIR__ . ' /vendor/autoload.php ' ;
use Cache Adapter Redis RedisCachePool ;
$ client = new Redis ();
$ client -> connect ( ' 127.0.0.1 ' , 6379 );
// Create a PSR6 cache pool
$ pool = new RedisCachePool ( $ client );
$ client = new Github Client ();
$ client -> addCache ( $ pool );
// Do some request
// Stop using cache
$ client -> removeCache ();
使用缓存,如果资源自上次以来没有发生变化,客户端将获得缓存的响应,而不会达到 github 施加的X-Rate-Limit
。
请参阅doc
目录以获取更详细的文档。
php-github-api
已根据 MIT 许可证获得许可 - 有关详细信息,请参阅许可证文件
请先阅读这篇文章。
该库由以下人员维护(按字母顺序排列):
感谢 GitHub 提供的高质量 API 和文档。