bc-automotive / master-api-client
bFlash Master Api Client
v1.0.0
2021-05-28 15:59 UTC
Requires
- guzzlehttp/guzzle: ^7.3
Requires (Dev)
- orchestra/testbench: ^6.18
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-09-29 06:21:32 UTC
README
bc-automotive/master-api-client 包是一个库,它可以简化您网站中 bFlash Master API 的集成。
安装
通过 composer 安装该包
composer require bc-automotive/master-api-client
使用方法
该 API 使用携带令牌进行身份验证。请联系 bFlash 支持 以获取您的身份验证令牌。
加密从文件
use \BcAutomotive\MasterApiClient\MasterApiClient; $client = new MasterApiClient($apiKey); $data = file_get_contents('/path/to/data.bdc'); $encrypted = $client->encrypt($data, $slaveName); file_put_contents('/path/to/data.sbdc', $encrypted['data']);
解密从文件
use \BcAutomotive\MasterApiClient\MasterApiClient; $client = new MasterApiClient($apiKey); $data = file_get_contents('/path/to/data.sbdc'); $decrypted = $client->decrypt($data); file_put_contents('/path/to/data.sbdc', $decrypted['data']);
Laravel 集成
该包提供了一个 Laravel 服务提供器和外观,以简化集成。因此,在您的 Laravel 项目中包含该包后,您可以将密钥添加到 .env 文件中
MASTER_API_KEY=your_key_here
并且使用外观
use MasterApiClient; $encrypted = MasterApiClient::encrypt($data, $slaveName); $decrypted = MasterApiClient::decrypt($data);
异常
MasterApiClient 类是围绕 Guzzle http 客户端库的小型包装器,因此该类可以抛出所有常规的 Guzzle 异常。您可以在Guzzle 文档 中提出问题。