mehdibo/ft-client
最新稳定版本:v1.0.1
Composer 安装命令:
composer require mehdibo/ft-client
包简介
Client library for Forty Two Intranet API
关键字:
README 文档
README
Client library to consume the 42 Intranet's API
Installation
composer require mehdibo/ft-client
Usage examples
Using the Authorization Code grant
include 'vendor/autoload.php'; $client = \Mehdibo\FortyTwo\Client\BasicClientFactory::createFromCredentials( 'CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI' ); $client->fetchTokenFromAuthCode($_GET['code']); $user = $client->get("/me");
Using the Client Credentials grant
include 'vendor/autoload.php'; $client = \Mehdibo\FortyTwo\Client\BasicClientFactory::createFromCredentials( 'CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI' ); // This is not necessary, if no token was fetched it will automatically fetch one using the Client Credentials grant $client->fetchTokenFromClientCredentials(); $cute = $client->get("/users/norminet");
Enumerating pages
This client comes with a method to easily enumerate pages of a paginated API endpoint.
include 'vendor/autoload.php'; $client = \Mehdibo\FortyTwo\Client\BasicClientFactory::createFromCredentials( 'CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URI' ); $users = $client->enumerate("/users", [ 'sort' => '-id', ]); try { foreach ($users as $user) { echo $user['login'] . PHP_EOL; } } catch (\Mehdibo\FortyTwo\Client\Exception\EnumerationRateLimited $e) { echo "Rate limited, retry in " . $e->retryAfter . " seconds\n"; echo "Stopped at page " . $e->reachedPage . "\n"; }
统计信息
- 总下载量: 118
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-04