1. Go to this page and download the library: Download smart-dato/post-it-sdk 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/ */
smart-dato / post-it-sdk example snippets
use SmartDato\PostIt\PostIt;
// Production (uses confirmed PRODUCTION_BASE_URL = https://apiw.gp.posteitaliane.it/gp/internet):
$client = PostIt::production(
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
scope: 'shipping',
);
// Or, for a custom base URL (test environment, on-premise, alternate contract):
$client = new PostIt(
baseUrl: 'https://your-tenant.posteitaliane.it/gp/internet',
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
scope: 'shipping',
grantType: 'client_credentials',
);
use SmartDato\PostIt\Data\AddressData;
use SmartDato\PostIt\Data\DeclarationData;
use SmartDato\PostIt\Data\ServicesData;
use SmartDato\PostIt\Data\WaybillData;
use SmartDato\PostIt\Data\WaybillRequestData;
use SmartDato\PostIt\Enums\PaymentMode;
use SmartDato\PostIt\Enums\PrintFormat;
use SmartDato\PostIt\Enums\Product;
$response = $client->createWaybill(new WaybillRequestData(
costCenterCode: 'CC100',
shipmentDate: new DateTimeImmutable(),
waybills: [
new WaybillData(
clientReferenceId: 'ORDER-123',
printFormat: PrintFormat::default(), // '1011' — 10×11 cm
product: Product::Express, // 'APT000901'
sender: new AddressData(
nameSurname: 'Sender Co',
contactName: 'Mario Rossi',
address: 'Via Roma',
streetNumber: '1',
zipCode: '00100',
city: 'Roma',
cellphone: '393331111111',
phone: '393331111111',
),
receiver: new AddressData(
nameSurname: 'Receiver Co',
contactName: 'Luigi Bianchi',
address: 'Via Milano',
streetNumber: '2',
zipCode: '20100',
city: 'Milano',
cellphone: '393332222222',
phone: '393332222222',
),
declared: [
new DeclarationData(weightGrams: 1500, heightCm: 20, lengthCm: 30, widthCm: 40),
],
services: new ServicesData(
multicolloCode: 'APT000901',
codAmount: 50.0,
codPaymentMode: PaymentMode::CashOnDelivery,
),
),
],
));
$waybillNumber = $response->waybills[0]['code'];
$labelPdfUrl = $response->waybills[0]['downloadURL'];
use SmartDato\PostIt\Data\InternationalData;
use SmartDato\PostIt\Data\ItemData;
use SmartDato\PostIt\Enums\ReceiverType;
new WaybillData(
clientReferenceId: 'ORDER-INT-1',
printFormat: PrintFormat::A4, // ZPL is not allowed for international
product: Product::InternationalStandard, // 'APT000904'
sender: $sender,
receiver: $receiver, // country e.g. 'GER1', countryName 'Germania'
declared: [
new DeclarationData(
weightGrams: 3000, heightCm: 10, lengthCm: 50, widthCm: 25,
description: 'Merce non destinata alla vendita',
packagingCode: 'C',
nationality: 'IT',
items: [
//