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 和文件。