PHP code example of inkr / smartpost-apiclient

1. Go to this page and download the library: Download inkr/smartpost-apiclient 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/ */

    

inkr / smartpost-apiclient example snippets


$client = new SmartPost\SmartPostApiClient((new SmartPost\SmartPostApiClientConf())
    ->setApiUrl('https://gateway.posti.fi/smartpost/api/ext/v1/')
    ->setAuthKey('apikey')
);

foreach ($client->getPlaces('EE') as $place)
{
    print_r($place);
}

$client->createOrders([
(new SmartPost\Model\Order\OrderCreateRequest())
    ->setReference('123')
    ->setContent('new shipment')
    ->setSource((new OrderCreateRequestSource())->setCountry('EE'))
    ->setRecipient((new SmartPost\Model\Order\OrderCreateRequestRecipient())
        ->setName('John Smith')
        ->setPhone('55667788')
    )
    ->setDestination((new SmartPost\Model\Order\OrderCreateRequestDestination())
        ->setCountry('EE')
        ->setPlaceId('01007225')
    )
]);

$client->getTracking(['barcode1', 'barcode2']);