daurensky / winfreight-php-sdk
Winfreight API的PHP SDK
1.0.4
2022-11-07 09:53 UTC
Requires
- php: ^7.1|^8.0
- ext-json: *
- guzzlehttp/guzzle: ~5.0
README
PHP Winfreight SDK使开发者能够轻松在PHP代码中访问Winfreight API。您可以通过Composer安装SDK或从最新版本下载单个zip或phar文件来快速开始。
跳转至
入门指南
- 获取Winfreight API的用户名和密码。
- 最低要求 - 运行SDK,您的系统需要有PHP >= 7.1。
composer require daurensky/winfreight-php-sdk
- 查看练习示例
快速示例
授权客户端
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Daurensky\WinfreightPhpSdk\Winfreight;
$username = {username};
$password = {password};
// Prev token data
$accessToken = {prev access token};
$expiresIn = {prev expires in};
$winfreight = new Winfreight($username, $password);
$winfreight->setToken($accessToken, $expiresIn);
if ($winfreight->rottenToken()) {
$authorization = $winfreight->renewToken();
/*
* Your token refresh. Ex:
* DB::insert('credentials', [
* 'access_token' => $authorization->getAccessToken();
* 'expires_in' => $authorization->getExpiresIn();
* ]);
*/
}
从API获取数据
<?php
$hubCodes = $winfreight->getHubCodes([
'GroupName' => 'Wintest',
'Province' => 'Western Cape',
'Suburb' => 'Constantiavale',
]);
$servCodee = $winfreight->getServCode([
'GroupName' => 'Wintest',
]);
$portalWaybill = $winfreight->createPortalWaybill([
'Waybill' => 'TEST005',
'Date' => '2021/01/13',
'SenderCustomerID' => 13,
...
]);