PHP code example of vldmrk / ukrposhta
1. Go to this page and download the library: Download vldmrk/ukrposhta 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/ */
vldmrk / ukrposhta example snippets
$config = new Ukrposhta\Data\Configuration();
$config->setBearer('string bearer');
$config->setToken('string token');
$config->addHeaders([
'Content-Type' => 'application/json'
]);
$config = new Ukrposhta\Data\Configuration();
$config->setBearer('string bearer');
$doc = new Ukrposhta\Doc($config);
$doc->save('./');
$params = [
'firstName' => 'Test_First_Name',
'lastName' => 'Test_Last_Name'
'middleName' => 'Test_Middle_Name'
];
$storage = new Ukrposhta\Data\Storage($params);
$storage->addData($storage);
$storage->setData('lastName', Test2_Last_Name);
$storage->firstName = 'Test2_First_Name';
$config = new Ukrposhta\Data\Configuration();
$config->setBearer('string bearer');
$config->setToken('string token');
$cities = new Ukrposhta\Directory\City($config)->getList();
$districts = Ukrposhta\Directory\District($config)->getList();
$regions = Ukrposhta\Directory\Region($config)->getList();
$streets = Ukrposhta\Directory\Street($config)->getList();
$params = new Ukrposhta\Data\Storage();
$params->region_id = 1;
$cities = new Ukrposhta\Directory\City($config)->getList($params);
$postoffices = new Ukrposhta\Directory\Postoffice($config)->getByCityId(1);
$storage = new Ukrposhta\Data\Storage();
$postoffices = new Ukrposhta\Directory\Postoffice($config)->getByPostIndex(72370);
$config = new Ukrposhta\Data\Configuration();
$config->setBearer('string bearer');
$config->setToken('string token');
$params = [
'firstName' => 'Марк'
'lastName' => 'Зотов'
'middleName' => 'Олегович'
'addressId' => 1250990
'type' => 'INDIVIDUAL'
];
$storage = new Ukrposhta\Data\Storage($params);
$client = new Ukrposhta\Client($config);
$client->save($storage);
$client->save($storage, 'string client UUID');
$client->get('customer id');
$config = new Ukrposhta\Data\Configuration();
$config->setBearer('string bearer');
$config->setToken('string token');
$form = new Ukrposhta\Form($config);
$resource = \GuzzleHttp\Psr7\Utils::tryFopen('/path/to/sticker.pdf', 'w');
$params = new Storage([
'sink' => $resource
])
$form->getSticker('shipment uuid or barcode', $params);