PHP code example of robinsaillard / tnt-express
1. Go to this page and download the library: Download robinsaillard/tnt-express 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/ */
robinsaillard / tnt-express example snippets
use RS\TntExpress\TntExpressInfo;
use RS\TntExpress\Services\ShipRequest;
$tnt = new TntExpressInfo("IdUser","password");
$tnt->setConsignementIdentity(string $customerReference, string $consignmentNumber = null)
->setCollectionDateTime(DateTime $collectionDateTime)
->setSender(string $name, string $addressLine1, string $addressLine2 = null, string $addressLine3 = null,
string $town, string $exactMatch = null, string $province = null, string $postcode = null ,
string $country, string $contactName, string $dialCode, string $telephone, string $mail)
->setDelivery(string $name, string $addressLine1, string $addressLine2 = null, string $addressLine3 = null,
string $town, string $exactMatch = null, string $province = null, string $postcode = null ,
string $country, string $contactName, string $dialCode, string $telephone, string $mail)
->setProduct(string $lineOfBusiness, string $groupId, string $subGroupId, string $type , string $id,
string $service, string $option = null)
->setAccount(string $accountNumber, string $accountCountry, string $contactName, string $dialCode,
string $mail, string $telephone)
->setOptionalElements(string $bulkShipment = null , string $specialInstructions = null , string $cashAmount = null,
string $cashCurrency = null , string $cashType = null , string $customControlled= null,
string $termsOfPayment = null)
->setPackage(int $itemNumber, float $poids, float $longueur, float $largeur, float $hauteur, string $description);
//$val = ["CREATE", "BOOK", "SHIP","PRINT"]
$xml = new ShipRequest($tnt, $val);
$html = $xml->getShippingRequest();
echo $html;
use RS\TntExpress\TntExpressInfo;
use RS\TntExpress\Services\TownPostRequest;
$tnt = new TntExpressInfo("IdUser","password");
$request = new TownPostRequest($tnt);
$result = $request->getTownPostRequest($pays = "FR", $ville, $postcode);
//output :
$result : array(
array(
"searchItem" => 1,
"postcode" => "NNNNN",
"ville" => "xxxxxxxxx"
),
[],
);