PHP code example of vegas0250 / cdeker

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

    

vegas0250 / cdeker example snippets




/**
 * Используем данные тестовой учетной записи.
 * 
 * @param string $clientId - Это "Account" из документации
 * @param string $clientSecret - Это "Secure password" из документации
 * @param boolean $test - Выполнение в тестовой среде, подробнее в документации 
 */
$cdekerClient = new Vegas0250\Cdeker\Client(
    'EMscd6r9JnFiQ3bLoyjJY6eM78JrJceI', 
    'PjLZkKBHEiLK3YsjtNrt3TGNG0ahs3kG', 
    true
);

/**
 * @param string $method -  Операясь на документацию находим необходимый 
 *                          запрос, например "Список офисов", в описании 
 *                          запроса указано GET или POST, в нашем случае 
 *                          GET, на данный момент необходимо писать в 
 *                          нижнем регистре "get".
 * @param string $url    -  Уникальный адрес запроса, в случае со 
 *                          "Списком офисов" получится "/v2/deliverypoints"
 * @param array $params -   Список передаваемых параметров, в виде
 *                          ассоциативного массива. 
 */
$result = $cdekerClient->request('get', '/v2/deliverypoints', [
    'city_code' => 250
]);

# Выведем ответ
print_r($result);


$cdekerClient = new Vegas0250\Cdeker\Client( '<clientId>', '<clientSecret>');

$cities = $cdekerClient->request('get', '/v2/deliverypoints', [
    'city_code' => 250
])

foreach($cities as $city) {
    // do something
}