digitickets/digitickets-php-api-client

提供对DigiTickets API的访问。

1.0.9 2022-01-24 15:26 UTC

This package is auto-updated.

Last update: 2024-08-24 21:12:10 UTC


README

提供对DigiTickets API的访问。目前这是一个相当基础的HTTP客户端。最终,它将完善,并包含API中所有端点的所有可能参数的方法。

安装

composer require digitickets/digitickets-php-api-client

使用

<?php

require __DIR__.'/vendor/autoload.php';

use DigiTicketsApiClient\ApiClient;

$apiClient = new ApiClient();
$apiClient->setApiKey('your_key_here');

$response = $apiClient->get('branches'); // Returns a PSR ResponseInterface.

// You can get an array of data from the response object with this method:
$branches = $apiClient->parseResponse($response);

print_r($branches);
// Returns:
// Array
// (
//     [0] => Array
//         (
//             [branchID] => 11
//             [name] => DigiTickets Demo Branch

测试

运行测试

phpunit tests

其中一些测试需要API密钥来访问API。您也可以在测试时指定不同的API来请求。这两者都将放入此仓库根目录下的.env文件中。复制.env.example来查看该文件应包含的内容。

cp .env.example .env

注意:不要使用实际公司(或您关心的测试公司)的API密钥进行这些测试,因为这些测试将创建和删除数据。