1. Go to this page and download the library: Download dinja/inpost-global-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/ */
dinja / inpost-global-sdk example snippets
$debug = true;
$timestamp = new \DateTime();
$timezone = new \DateTimeZone('Europe/Rome');
$timestamp->setTimezone($timezone);
$recipient = new ShipmentContact();
$recipient->setFirstName("Mario")
->setLastName("Rossi")
->setPhonePrefix("+39")
->setPhoneNumber("0803009954")
->setEmail("[email protected]");
$sender = new ShipmentContact();
$sender->setCompanyName("Dinja Srl")
->setPhonePrefix("+39")
->setPhoneNumber("0803009954")
->setEmail("[email protected]");
$origin = new ShipmentAddress();
$origin->setStreet("Via Leonardo da Vinci")
->setHouseNumber("22")
->setCity("Polignano a Mare")
->setPostalCode("70044")
->setCountryCode("IT");
$destination = new ShipmentPoint();
$destination->setCountryCode("IT")
->setPointName("AAATESTPOK9");
$parcel = new ShipmentParcel();
$parcel->setWeightAmount("1")
->setWeightUnit("KG")
->setHeight("1")
->setLength("1")
->setWidth("1")
->setDimensionsUnit("CM");
$shipment = new Shipment();
$shipment->setSender($sender)
->setRecipient($recipient)
->setOriginAddress($origin)
->setDestinationPoint($destination)
->setParcel($parcel);
$request = new ShipmentRequest("inpost_api_client_id", "inpost_api_client_secret", $debug);
$request->setLabelFormat("PDF_URL")
->setShipment($shipment);
$shipmentResponse = $request->call();
if ($shipmentResponse->hasError()) {
echo $shipmentResponse->getTitle();
} else {
$shipmentLabelUrl = $shipmentResponse->getLabel();
}