cervon/tms-php-client
最新稳定版本:v0.0.8
Composer 安装命令:
composer require cervon/tms-php-client
包简介
A PHP client for the TMS API.
README 文档
README
use Cervon\Tms\Tms; $CLIENT_ID = 'MY_CLIENT_ID'; $CLIENT_SECRET = 'MY_CLIENT_SECRET'; $TMS_BASE_URL = 'https://my-tms-url.com/' $tms = new Tms($CLIENT_ID, $CLIENT_SECRET, $TMS_BASE_URL); $authenticator = $tms->getAccessToken(); $tms->authenticate($authenticator); $jobs = $tms->listJobs(); foreach ($jobs as $job) { echo "Job #{$job->number} (ID: {$job->_id})\n"; }
Installation
composer require cervon/tms-php-client
Usage
You can authenticate using your TMS client id, client secret and base URL.
use Cervon\Tms\Tms; $CLIENT_ID = 'MY_CLIENT_ID'; $CLIENT_SECRET = 'MY_CLIENT_SECRET'; $TMS_BASE_URL = 'https://my-tms-url.com/' $tms = new Tms($CLIENT_ID, $CLIENT_SECRET, $TMS_BASE_URL); $authenticator = $tms->getAccessToken();
Disabling SSL verify
By default, SSL verification is enabled. If you want to test the API locally, you can disable SSL verification.
$tms = new Tms($CLIENT_ID, $CLIENT_SECRET, $TMS_BASE_URL, verifySsl: false);
Caching authenticator
To avoid sending authentication requests every time, you can serialize and cache the authenticator object. Example in Laravel:
use Cervon\Tms\Tms; use Illuminate\Support\Facades\Cache; $tms = new Tms($CLIENT_ID, $CLIENT_SECRET, $TMS_BASE_URL); $authenticator = Cache::remember('tms_authenticator', 3600, function () use ($tms) { // Fresh token when cache is empty return $tms->getAccessToken(); }); // Refresh token when expired if ($authenticator->hasExpired()) { $authenticator = $tms->getAccessToken(); Cache::put('tms_authenticator', $authenticator, 3600); } $tms->authenticate($authenticator);
Security
If you discover any security related issues, please email support@cervon.nl instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 44
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-16