PHP code example of metaship-ru / metaship-php-sdk
1. Go to this page and download the library: Download metaship-ru/metaship-php-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/ */
metaship-ru / metaship-php-sdk example snippets
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');
$client = new MetaShipAPIClient('URL','api-key', 'api-secret');
use MetaShipRU\MetaShipPHPSDK\Request\Offer\OfferRequest;
use GuzzleHttp\Exception\BadResponseException;
use MetaShipRU\MetaShipPHPSDK\Component\ResponseFormatter\ErrorResponseFormatter;
use MetaShipRU\MetaShipPHPSDK\Component\ResponseFormatter\OfferResponseFormatter;
use MetaShipRU\MetaShipPHPSDK\MetaShipAPIClient;
$offersRequest = new OfferRequest();
$offersRequest->cityTo = 'Москва';
$offersRequest->zipTo = 115612;
$offersRequest->paymentSum = 1000;
$offersRequest->weight = 1.2;
$offersRequest->length = 10;
$offersRequest->height = 10;
$offersRequest->width = 10;
$offersRequest->deliveryType = 'courier';
try {
$response = $client->getOffers($offersRequest);
$offerResponse = OfferResponseFormatter::format($response);
} catch (BadResponseException $exception) {
$errorResponse = ErrorResponseFormatter::format($exception->getResponse());
}