PHP code example of cdek-php / api

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

    

cdek-php / api example snippets


use Cdek\Client;

$client = new Client('EMscd6r9JnFiQ3bLoyjJY6eM78JrJceI', 'PjLZkKBHEiLK3YsjtNrt3TGNG0ahs3kG');

use Cdek\Client;
use Cdek\Enums\Endpoint;

$client = new Client('client-id', 'client-secret', Endpoint::PROD);

// cdek.php

use Cdek\Client;

$client = new Client; // без client_id, client_secret и endpoint

$token = $client->getToken();

# https://api-docs.cdek.ru/36982648.html
$client->api('get', 'deliverypoints', [
    'size' => 10,
]);

# https://api-docs.cdek.ru/36982648.html
$client->get('deliverypoints', [
    'size' => 10,
]);

$client->post(..., [...]);

$client->patch(..., [...]);

$client->delete(..., [...]);
bash
composer