PHP code example of bricre / royalmail-tracking-v2-sdk
1. Go to this page and download the library: Download bricre/royalmail-tracking-v2-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/ */
bricre / royalmail-tracking-v2-sdk example snippets
use GuzzleHttp\Client as Guzzle;
use OpenAPI\Runtime\Client;
use OpenAPI\Runtime\ResponseHandler\JsonPsrResponseHandler;
use OpenAPI\Runtime\ResponseHandlerStack;
use RoyalMail\SDK\V2Tracking\ResponseTypes;
Client::configure(
new Guzzle([
'base_uri' => 'https://api.royalmail.net',
'headers' => [
'Accept' => 'application/json',
'X-Accept-RMG-Terms' => 'yes',
'X-IBM-Client-Id' => getenv('X-IBM-Client-Id'),
'X-IBM-Client-Secret' => getenv('X-IBM-Client-Secret'),
]
]),
new ResponseHandlerStack([
JsonPsrResponseHandler::setResponseTypes(new ResponseTypes())
]),
);
use RoyalMail\SDK\V2Tracking\Api\API;
use RoyalMail\SDK\V2Tracking\Model\EventsSuccessResponse;
use RoyalMail\SDK\V2Tracking\Model\SignatureSuccessResponse;
use RoyalMail\SDK\V2Tracking\Model\SummarySuccessResponse;
$API = new API();
/** @var SummarySuccessResponse $summery */
$summary = $API->summary(['mailPieceId'=>'AA999999999GB']);
/** @var EventsSuccessResponse $events */
$events = $API->events('AA999999999GB');
/** @var SignatureSuccessResponse $signature */
$signature = $API->signature('AA999999999GB');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.