Skip to content

Instantly share code, notes, and snippets.

@teddychan
Created July 31, 2014 08:39
Show Gist options
  • Save teddychan/675f9a7ecca52512de91 to your computer and use it in GitHub Desktop.
Save teddychan/675f9a7ecca52512de91 to your computer and use it in GitHub Desktop.
<?php
$request = array();
$request['tracking'] = array();
$request['tracking']['tracking_number'] = 'RA123456789US';
// all the following value are optional
$request['tracking']['slug'] = 'usps'; // AfterShip support auto detect courier, if you don't know which couriers is. just skip this line.
$request['tracking']['title'] = 'iPhone Case';
$request['tracking']['order_id'] = '10001';
$request['tracking']['order_id_path'] = 'http://www.mystore.com/order.php?order_id=10001';
$request['tracking']['customer_name'] ='Tim Cook';
$request['tracking']['emails'] = '[email protected],[email protected]';
$request['tracking']['smses'] = '+18175698900';
$request['tracking']['destination_country_iso3'] = 'USA';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://api.aftership.com/v3/trackings');
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'aftership-api-key: YOUR AfterShip API key',
'Content-Type: application/json',
));
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($request));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($curl);
curl_close($curl);
echo $content;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment