digitickets/generic-api-client

用于向API发送请求的接口。

1.0.6 2023-09-21 12:28 UTC

This package is auto-updated.

Last update: 2024-09-21 14:38:59 UTC


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