Современный и удобный PHP-клиент Yandex.Direct API.
- PHP 7.2 и выше
$ composer require gladyshev/yandex-direct-client
$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' => [...]
// ]