1. Go to this page and download the library: Download appwilio/russianpost-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/ */
appwilio / russianpost-sdk example snippets
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$log = (new Logger('pochta.ru'))
->pushHandler(new StreamHandler('path/to/your.log', Logger::INFO));
// SingleAccessClient, PacketAccessClient, DispatchingClient
$client->setLogger($log);
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$this->app->singleton('appwilio.russianpost.logger', static function () {
return (new Logger('pochta.ru'))
->pushHandler(new StreamHandler('path/to/your.log', Logger::INFO));
});
$response = $tracker->getTrackingEvents($ticket->getId());
echo $response->getPreparedAt()->format('d.m.Y в h:m:s');
foreach ($response as $item) {
echo $item->getBarcode();
foreach ($item as $events) {
echo $events->getOperationId();
echo $events->getAttributeId();
echo $events->getPerformedAt()->format('d.m.Y в h:m:s'); // 17.09.2019 в 17:20:48
}
}
use GuzzleHttp\Client as GuzzleClient;
use Appwilio\RussianPostSDK\Dispatching\DispatchingClient;
$dispatching = new DispatchingClient(
$login = 'login', $password = 'secret', $token = 'QWERTY', new GuzzleClient()
);
use Appwilio\RussianPostSDK\Dispatching\Enum\MailType;
use Appwilio\RussianPostSDK\Dispatching\Enum\MailCategory;
use Appwilio\RussianPostSDK\Dispatching\Enum\MailEntryType;
use Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Requests\CalculationRequest;
$response = $dispatching->services->calculate(
CalculationRequest::create('123456', 200)
->ofMailType(MailType::PARCEL_POSTAL())
->ofMailCategory(MailCategory::ORDINARY())
->ofEntriesType(MailEntryType::GOODS())
->fragile()
->withSmsNotice()
);
echo $response->getTotal()->getRate();
echo $response->getTotal()->getVAT(); // НДС
use Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Requests\NormalizeFioRequest;
$response = $dispatching->services->normalizeFio(
NormalizeFioRequest::one('иванов иван иванович')
);
if ($response[0]->isUseful()) {
echo $response[0]->getFirstName().' '.$response[0]->getLastName(); // Иван Иванов
}
use Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Requests\NormalizeAddressRequest;
$response = $dispatching->services->normalizeAddress(
NormalizeAddressRequest::one('Москва варшавское шоссе 37-45')
);
use Appwilio\RussianPostSDK\Dispatching\Endpoints\Services\Requests\NormalizePhoneRequest;
$response = $dispatching->services->normalizePhone(NormalizePhoneRequest::one('89001234567'));
use Appwilio\RussianPostSDK\Dispatching\Enum\PrintType;
$pdf = $dispatching->documents->orderF7Form(
'12345678', new \DateTime('2019-01-01'), PrintType::PAPER()
);
$pdf = $dispatching->documents->orderF112Form('12345678', new \DateTime('2019-01-01'));
$zip = $dispatching->documents->orderFormsBundleBacklog('12345678', new \DateTime('2019-01-01'));
use Appwilio\RussianPostSDK\Dispatching\Enum\PrintType;
$zip = $dispatching->documents->orderFormBundle(
'12345678', new \DateTime('2019-01-01'), PrintType::THERMO()
);