PHP code example of daurensky / winfreight-php-sdk

1. Go to this page and download the library: Download daurensky/winfreight-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

daurensky / winfreight-php-sdk example snippets




aurensky\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();
     * ]);
    */
}



$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,
    ...
]);