PHP code example of gwinn / boxberry-sdk

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

    

gwinn / boxberry-sdk example snippets


$yourHttpClientFactory = new \Gwinn\Boxberry\Factory\HttpClientFactory();
$apiClientFactory = new \Gwinn\Boxberry\Factory\ApiClientFactory($yourHttpClientFactory);
$boxberryClient = $apiClientFactory->create(API_TOKEN);

$listCitiesRequest = new \Gwinn\Boxberry\Model\Request\Geography\ListCitiesRequest();
$listCitiesRequest->countryCode = '643';

try{
    // получение городов
    $response = $boxberryClient->listCities($listCitiesRequest);
}catch (ApiException $exception){
    echo $exception->getMessage();
    exit(255);
}

$yourHttpClientFactory = new \Gwinn\Boxberry\Factory\HttpClientFactory();
$apiClientFactory = new \Gwinn\Boxberry\Factory\ApiClientFactory($yourHttpClientFactory);
$boxberryClient = $apiClientFactory->create(API_TOKEN);

$parcel = new \Gwinn\Boxberry\Model\Request\OrderInfo\ParcelInfoRequest\Parcel();
$parcel->orderId = '123';
$parcelInfoRequest = new \Gwinn\Boxberry\Model\Request\OrderInfo\ParcelInfoRequest();
$parcelInfoRequest->parcels = [$parcel];

try{
    // получение информации о посылке
    $response = $boxberryClient->parcelInfo($parcelInfoRequest);
}catch (ApiException $exception){
    echo $exception->getMessage();
    exit(255);
}