PHP code example of alhoqbani / smsa-webservice

1. Go to this page and download the library: Download alhoqbani/smsa-webservice 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/ */

    

alhoqbani / smsa-webservice example snippets


$result = $smsa->status('290019315792');
var_dump($smsa->data);

$track = $smsa->track('290019315792');

if (track->success) {
    var_dump($track->data);
} else {
    var_dump($track->error);
}

try {
    $pdf = $smsa->awbPDF('290019315810');
    header('Content-type: application/octet-stream');
    header('Content-disposition: attachment;filename=awb.pdf');
    echo $pdf->data; die();

} catch (\Alhoqbani\SmsaWebService\Exceptions\RequestError $e) {
    echo $e->getMessage();
    var_dump($e->smsaResponse)
}



use \Alhoqbani\SmsaWebService\Smsa;
use \Alhoqbani\SmsaWebService\Models\Shipment;
use \Alhoqbani\SmsaWebService\Models\Customer;
use \Alhoqbani\SmsaWebService\Models\Shipper;

$smsa = new Smsa($passKey);
// Create a customer
$customer = new Customer(
    'Customer Name', //customer name
    '0500000000', // mobile number. must be > 9 digits
    '10 King Fahad Road', // street address
    'Jeddah' // city
);

$shipment = new Shipment(
    time(), // Refrence number
    $customer, // Customer object
    Shipment::TYPE_DLV // Shipment type.
      );

$awb = $smsa->createShipment($shipment);

echo $awb->data; // 290019315792

 
$customer
    ->setEmail('[email protected]')
    ->setAddressLine2('Building 10, Apartment 1')
    ->setPOBox('12345')
    ->setZipCode('11411')
    ->setTel1('0110000000')
    ->setTel2('0120000000');

// To add shipper details to the shipment
$shipper = new Shipper(
    'Shipper Name (LLC)', // shipper name
    'Shipper Employee', // contact name
    '1 Main Road', // address line 1
    'Riyadh', // city
    'Saudi Arabia', // country
    '0110000000' // phone
);

$shipment->setShipper($shipper);

$result = $smsa->cancel('AWB NUMBER')
var_dump($result->jsonSerialize())

$smsa->shouldUseExceptions = false; // Disable throwing exceptions by the library

$cities = $smsa->cities();

if( $cities->success) {
    var_dump($cities->data)
} else {
    var_dump($cities->error)
}

$retails = $smsa->retails();
var_dump($retails); 
// or by city (route code):
$retails =  $smsa->retailsIn('TUU');
 php


use \Alhoqbani\SmsaWebService\Smsa;

$smsa = new Smsa($passKey);