PHP code example of appwilio / cdek-sdk
1. Go to this page and download the library: Download appwilio/cdek-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 / cdek-sdk example snippets
// config/app.php
'providers' => [
// ...
\Appwilio\CdekSDK\LaravelCdekServiceProvider::class
// ...
]
// config/services.php
'cdek' => [
'account' => env('CDEK_ACCOUNT', ''),
'password' => env('CDEK_PASSWORD', ''),
'guzzle_options' => [ // необязательные параметры
'base_uri' => 'https://integration.cdek-asia.cn',
'timeout' => 5
]
],
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');
$client = new \Appwilio\CdekSDK\CdekClient('account', 'password', $guzzleOptions = [
'timeout' => 5
]);
use Appwilio\CdekSDK\Requests\CalculationRequest;
// для выполнения авторизованного запроса используется
// $request = CalculationRequest::withAuthorization();
$request = (new CalculationRequest())
->setSenderCityPostCode('295000')
->setReceiverCityPostCode('652632')
->addGood([
'weight' => 0.2,
'length' => 10,
'width' => 10,
'height' => 10,
]);
$response = $client->sendCalculationRequest($request)
use \Appwilio\CdekSDK\Common\Order;
use Appwilio\CdekSDK\Requests\StatusReportRequest;
$request = (new StatusReportRequest())
->setShowHistory();
$request->addOrder(new Order(['Number' => '89754564']));
$request->addOrder(new Order(['DispatchNumber' => '2222222222']));
$response = $client->sendStatusReportRequest($request);