schенка-io / api-client
适用于没有SDK的应用程序的简单CURL基于的API客户端
v0.4.0
2023-08-27 21:47 UTC
Requires
- php: ^8.1
- ext-curl: *
Requires (Dev)
- laravel/pint: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^10.1
README
适用于没有SDK的应用程序的简单CURL基于的API客户端
安装
composer require schenke-io/api-client
用法
创建一个扩展 BaseClient
或 BaseJsonClient
的本地类。
#app/MyClass.php class MyClass extends BaseClient { public function getAuthHeader(): array { return [ 'Authorization: Bearer <YOUR-TOKEN>' ]; } }
然后这样使用这个类
#app/MyClass.php $api = new MyClass('https://example.com/api/v2/'); $result = $api->get('/users'); print_r($result);
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近更改的更多信息。
许可证
MIT许可证(MIT)。请参阅 许可证文件 获取更多信息。