Вопрос нехватки знания. Сам директолог, фриланс.
Необходимо для себя временное костыльное решение вывода баланса аккаунтов директа.
Вывод апи хочу преобразовать в HTML. Проблема с разбором массива, не могу вдуплить как.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://api.direct.yandex.ru/live/v4/json/');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'{
"method": "AccountManagement",
"token": "AgAAAAA8-9-uAAVNXerAXgmXDkXquGRgLPMjN30",
"param": {"SelectionCriteria": {}, "Action": "Get"}}'); //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [
'POST /json/v5/ads/ HTTP/1.1',
'Host: api.direct.yandex.com',
'Authorization: Bearer AQAAAAAW-**********************************',
'Accept-Language: ru',
'Client-Login: *************@yandex.ru',
'Content-Type: application/json; charset=utf-8',
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$server_output = curl_exec ($ch);
curl_close ($ch);
$balance = json_decode($server_output,true);
print_r ($balance);
echo $balance['Amount'];
echo $balance['AccountID'];
echo $balance['data']['AccountID'];
echo $balance['0']['AccountID'];
Выводит
Array ( [data] => Array ( [ActionsResult] => Array ( ) [Accounts] => Array ( [0] => Array ( [Login] => pl4tpass [Discount] => 0 [Currency] => RUB [AmountAvailableForTransfer] => 0 [SmsNotification] => Array ( [MoneyOutSms] => No [PausedByDayBudgetSms] => Yes [SmsTimeTo] => 21:00 [MoneyInSms] => No [SmsTimeFrom] => 09:00 ) [Amount] => 0 [AgencyName] => [EmailNotification] => Array ( [SendWarn] => [MoneyWarningValue] => 20 [PausedByDayBudget] => Yes [Email] => pl4tpass@yandex.ru ) [AccountID] => 49797112 ) ) ) )