PHP code example of cjario / omniship-australia-post

1. Go to this page and download the library: Download cjario/omniship-australia-post 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/ */

    

cjario / omniship-australia-post example snippets


$carrier = \Omniship\Omniship::create('AustraliaPost_Domestic');  
$carrier->setApiKey('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM');
Or
$carrier->setApiKey(Yii::$app->params['AUSPOST_API_KEY']);

        
// Get list of boxes provided by carrier
$resp = $carrier->box()->send();
print_r($resp->getData());

// Retrieve a list of available domestic postage services
 $serviceArr = [
     'fromPostcode' => '2000',
     'toPostcode' => '3000',
     'parcelLengthInCMs' => 22,
     'parcelWidthInCMs' => 16,
     'parcelHeighthInCMs' => 7.7,
     'parcelWeightInKGs' => 1.5,
 ];
 $resp = $carrier->service()->sendData($serviceArr);
 print_r($resp->getData());

// Calculate total delivery price
 $serviceArr = [
     'fromPostcode' => '2000',
     'toPostcode' => '3000',
     'parcelLengthInCMs' => 22,
     'parcelWidthInCMs' => 16,
     'parcelHeighthInCMs' => 7.7,
     'parcelWeightInKGs' => 1.5,
 ];
 $resp = $carrier->postage(['parcelType'=> 'AUS_PARCEL_EXPRESS'])->sendData($serviceArr);
 print_r($resp->getData());