AfterShip PHP SDK

PHP SDK to integrate with Aftership API

Aftership PHP SDK

Installation

Using Composer

 "require": {
        ....
        "abishekrsrikaanth/aftership-php-sdk": "1.0"
    },

Get all our supported couriers list.

require 'vendor/autoload.php';

$courier = new AfterShip\Couriers('AFTERSHIP_API_KEY');
$response = $courier->get();

Detect courier by tracking number

require 'vendor/autoload.php';

$courier = new AfterShip\Couriers('AFTERSHIP_API_KEY');
$response = $courier->detect('1234567890Z');

Create a new tracking number

List of data for the API

require 'vendor/autoload.php';

$tracking = new AfterShip\Tracking('AFTERSHIP_API_KEY');
$tracking_info = array(
    'slug'              => 'dhl',
    'tracking_number'   => 'RA123456789US',

);
$response = $tracking->create($tracking_info);

Return the latest 100 created trackings in past 30 days from the user account.

List of allowed parameters for the options

require 'vendor/autoload.php';

$tracking = new AfterShip\Tracking('AFTERSHIP_API_KEY');
$options = array(
    'page'=>1,
    'limit'=>10
);

$response = $tracking->get($options)

Return a tracking result with all the detail checkpoints

Fields for the request

require 'vendor/autoload.php';

$tracking = new AfterShip\Tracking('AFTERSHIP_API_KEY');
$response = $tracking->info('dhl','RA123456789US',array('title','order_id'));

Update tracking record and return all the detail, exclude the checkpoints

List of allowed parameters

require 'vendor/autoload.php';

$tracking = new AfterShip\Tracking('AFTERSHIP_API_KEY');
$params = array(
    'smses'             => array(),
    'emails'            => array(),
    'title'             => '',
    'customer_name'     => '',
    'order_id'          => '',
    'order_id_path'     => '',
    'custom_fields'     => array()
);
$response = $tracking->update('dhl','RA123456789US',$params);

Reactivate Tracking

require 'vendor/autoload.php';

$tracking = new AfterShip\Tracking('AFTERSHIP_API_KEY');
$response = $tracking->reactivate('dhl','RA123456789US');

Finding Last Checkpoint

require 'vendor/autoload.php';

$checkpoint = new AfterShip\LastCheckPoint('AFTERSHIP_API_KEY');
$response = $checkpoint->get('dhl','RA123456789US');

Adding Guzzle Plugins

Guzzle Plugins

require 'vendor/autoload.php';

$history = new HistoryPlugin();
$async = new AsyncPlugin();
$logPlugin = new LogPlugin($adapter, MessageFormatter::DEBUG_FORMAT);

$guzzlePlugins = array($history, $async, $logPlugin);

$tracking = new AfterShip\Tracking('AFTERSHIP_API_KEY', $guzzlePlugins);
$couriers = new AfterShip\Couriers('AFTERSHIP_API_KEY', $guzzlePlugins);