digitickets / generic-api-client
用于向API发送请求的接口。
1.0.6
2023-09-21 12:28 UTC
Requires
- php: ^7.0.0|^8.0.0
- ext-json: *
- guzzlehttp/guzzle: ^6.2|^7.0
Requires (Dev)
- phpunit/phpunit: ^6
README
提供访问API的标准接口。
安装
composer require digitickets/generic-api-client
使用方法
<?php
require __DIR__.'/vendor/autoload.php';
use GenericApiClient\ApiClient;
$apiClient = new ApiClient('https://some-api.com);
$response = $apiClient->get('dogs'); // Returns a PSR ResponseInterface.
// You can get an array of data from the response object with this method:
$dogs = $apiClient->parseResponse($response);
print_r($dogs);
// Returns:
// Array
// (
// [0] => Array
// (
// [dogID] => 11
// [name] => Merlin
测试
在PHP 8上安装
composer install --ignore-platform-reqs
运行测试
composer test