Informatie utila:
Daca nu aveti un cont va puteti crea un cont aici : http://www.atp-curierat.com/client/register
Pentru activarea serviciului de API trebuie sa aveti un cont existent.
Accesul la API se face pe baza de adresa de email si parola.
Link-ul serviciului este: http://atp-curierat.com/api/v1/ .
Schimbul de informatii intre sisteme se face prin codificarea Json .
Daca nu aveti un cont va puteti crea un cont aici : http://www.atp-curierat.com/client/register
Puteti obtine statusul unei awb, folosind exemplul de mai jos.
<?php
$url = 'http://www.atp-curierat.com/api/v1/tracking/';
$c = curl_init($url);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, "email=$email&password=$password&awb_number=$code");//awb_number-numar awb ex:10239048BU73
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($c);
curl_close($c);
$query = json_decode($page);
?>
<?php
$url = 'http://www.atp-curierat.com/api/v1/price/';
$data = array("email" => $email,
"password" => $password,
"awb_service" => "Transit",
"awb_payer" => $awb_payer, // Platitor transport = 1 -Expeditor / 2- Destinatar
"awb_rambus_value" => $rambus_value, //Valoare ramburs = Numar real
"awb_rambus_pay" =>"",//1 – Numerar, 2 – Cont colector prin banca.
"awb_insurance" => $insurance, // Asigurare pentru transport= true sau false | Daca 'true' atunci awb_value este obligatoriu
"awb_value" => $awb_value,//Valoare transport = Numar real
"awb_parcel" => $awb_parcel,// Numar colete = Numar natural intre 0-999
"awb_envelope" => $awb_envelope, //Numar plicuri = Numar natural intre 0-999
"awb_weight" => $awb_weight,//Greutate totala = Numar natural
"to_county" => $to_county, //Judet destinatar
"to_locality" => $to_locality,//Localitatea destinatara
"to_postalcode" => $to_postalcode);//Cod postal destinatar = 6 cifre/
$c = curl_init($url);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$query = curl_exec($c);
curl_close($c);
$price = json_decode($query);
?>
<?php
$url = 'http://www.atp-curierat.com/api/v1/cancel/';
$data = array("email" => $email,
"password" => $password,
"awb_number" => $awb_number); //awb_number - este numarul awb
$c = curl_init($url);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($c);
curl_close($c);
$query= json_decode($page);
print_r($query);
?>
<?php
$url = 'http://www.atp-curierat.com/api/v1/label/';
$data = array("email" => $email,
"password" => $password,
"awb_number" => $awb_number);
$c = curl_init($url);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($c);
curl_close($c);
$result = json_decode($page);
echo $result->result;
?>
Daca in contul de utilizator, sectiunea preferinte ( http://www.atp-curierat.com/account/pref ) , aveti activata optiunea de listare sub forma de eticheta , puteti folosi codul de mai jos pentru printare.
<?php
$url = 'http://www.atp-curierat.com/api/v1/label/';
$data = array("email" => $email,
"password" => $password,
"awb_number" => $awb_number);
$c = curl_init($url);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_BINARYTRANSFER, true);
$page = curl_exec($c);
curl_close($c);
$result = json_decode($page);
$result->result=base64_decode($result->result);
header("Cache-Control: public");
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=$awb_number.pdf");
header("Content-Length: " . strlen($result->result));
echo $result->result; ?>
Un awb creat prin seviciul API are intotdeauna statusul 'Creat'. Pentru plasarea unei comenzi catre ATP Transit , trebuie sa intrat pe borderoul disponibil la http://www.atp-transit.com , si sa plasati comanda.
<?php
$url = 'http://www.atp-curierat.com/api/v1/order/';
$data = array("email" => $email,
"password" => $password,
"awb_service" => "Transit",
"awb_payer" => $awb_payer, // Platitor transport = 1 -Expeditor / 2- Destinatar
"awb_rambus_value" => $rambus_value, //Valoare ramburs = Numar real
"awb_rambus_pay" =>"",//1 – Numerar, 2 – Cont colector prin banca.
"awb_insurance" => $insurance // Asigurare pentru transport= true sau false | Daca 'true' atunci awb_value este obligatoriu
"awb_value" => $awb_value, //Valoare transport = Numar real
"awb_parcel" => $awb_parcel,// Numar colete = Numar natural intre 0-999
"awb_envelope" => $awb_envelope, //Numar plicuri = Numar natural intre 0-999
"awb_weight" => $awb_weight, //Greutate totala = Numar natural
"to_name" => $to_name, //Nume destinatar
"to_country" => $to_country, //Tara destinatara
"to_county" => $to_county, //Judetul destinar
"to_locality" => $to_locality, //Localitatea destinatara
"to_postalcode" => $to_postalcode, //Cod postal destinatar = 6 cifre/
"to_address" => $to_address,//Adresa destinatarului
"to_person" => $to_name, //Persoana de contact destinatar
"to_person_phone" => $to_person_phone, //Telefonul de contact al destinatarului (Important pentru notificari)
"to_person_email" => $to_person_email);//Adresa de email a destinatarului
$c = curl_init($url);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($c);
curl_close($c);
$result = json_decode($page);
print_r($result);
?>
stdClass Object
(
[success] => 1 //true-interogarea s-a rulat cu succes
[result] => 10000000MM70 //numarul de comanda (awb)
[barcodes] => Array //lista cu codurile de bare a coletelor
(
[0] => 10000000MM70-P1
[1] => 10000000MM70-P2
[2] => 10000000MM70-P3
)
)
stdClass Object
(
[success] => //false - exista o problema in datele trimise
[result] => awb_rambus_pay=> Pentru rambus este nevoie sa specificati modul de returnare! // mesajul de eroare.
)