sportmaster/api-client
Composer 安装命令:
composer require sportmaster/api-client
包简介
A flexible and extensible PHP client for the Sportmaster Seller API
README 文档
README
A flexible and extensible PHP client for interacting with the Sportmaster Seller API. This package supports both native PHP and frameworks like Laravel, with easy configuration, token management, and logging.
Installation
Install the package via Composer:
composer require sportmaster/api-client
Usage
Basic Example (Native PHP)
use Sportmaster\Api\Client; use Sportmaster\Api\Endpoints\AuthClient; use Sportmaster\Api\Request\AuthRequest; $client = new Client(); $authClient = new AuthClient($client); $request = new AuthRequest('your_client_id', 'your_client_secret'); $response = $authClient->authenticate($request); echo $response->getAccessToken(); // Outputs the access token
Laravel Integration
Add the service provider to config/app.php:
'providers' => [ Sportmaster\Api\Laravel\SportmasterApiServiceProvider::class, ]
Use the client in your application:
use Sportmaster\Api\Endpoints\AuthClient; use Sportmaster\Api\Request\AuthRequest; $client = app(\Sportmaster\Api\Client::class); $authClient = new AuthClient($client); $request = new AuthRequest('your_client_id', 'your_client_secret'); $response = $authClient->authenticate($request); echo $response->getAccessToken();
Configuration
- Token Storage: By default, tokens are stored in a JSON file (
.sportmaster_token.json). You can implementTokenStorageInterfacefor custom storage. - Logger: By default, logs are written to
sportmaster_api.log. ImplementLoggerInterfacefor custom logging. - HTTP Client: Uses Guzzle by default. Pass a custom
ClientInterfaceto theClientconstructor for alternative HTTP clients.
Requirements
- PHP ^8.1
- Guzzle HTTP Client ^7.5
- Monolog ^3.0
Testing
Run tests with PHPUnit:
composer test
Documentation
Detailed documentation for each class is available in the docs/ directory.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-08