PHP code example of gladyshev / yandex-direct-client

1. Go to this page and download the library: Download gladyshev/yandex-direct-client 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/ */

    

gladyshev / yandex-direct-client example snippets


$credentials = \Gladyshev\Yandex\Direct\Credentials::client(
    getenv('_TOKEN_')
); 

$httpClient = new \GuzzleHttp\Client(); // Guzzle 7 или любой другой PSR-18 HTTP-клиент

$client = new \Gladyshev\Yandex\Direct\Client(
    $credentials,
    $httpClient
);

$response = $client->campaigns->get(
    ['Ids' => [123545345, 23423234]],  // SelectionCriteria
    ['Status', 'Currency', 'Funds']    // FieldNames
);

print_r($response);

// [
//     'request_id' => 8695244274068608439,
//     'units_used_login' => 'ttt-agency',
//     'units' => [
//         'debit' => 10, 
//         'rest' => 20828,
//         'limit' => 64000
//     ],
//     'result' => [...]
// ]