PHP code example of digitalpianism / nzpost-client

1. Go to this page and download the library: Download digitalpianism/nzpost-client 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/ */

    

digitalpianism / nzpost-client example snippets


use DigitalPianism\NzPostClient\NzPostClient;

$clientID = 'NZPOST_CLIENT_ID';
$secret = 'NZPOST_CLIENT_SECRET';

$Client = new NzPostClient($clientID, $secret);

use Symfony\Component\Cache\Simple\FilesystemCache;
use DigitalPianism\NzPostClient\NzPostClient;

$cache = new FilesystemCache();
$ttl = 31536000; // One year cache TTL

$clientID = 'NZPOST_CLIENT_ID';
$secret = 'NZPOST_CLIENT_SECRET';

$Client = new NzPostClient($clientID, $secret, $cache);
$Client->setTTL($ttl);

$query = '1 Queen street';
$suggestedAddresses = $Client->suggest($query);

$addressLines = [
    '1 Queen street',
    'CBD',
    'Auckland'
 ];
 $addresses = $Client->find($addressLines);

$dpid='3111226';
$addressDetails = $Client->details($dpid);

$query = 'queen';
$suggestedAddresses = $Client->suggestPartial($query);

$uniqId = 82868;
$response = $Client->partialDetails($uniqId);