Вот пример запроса
$name='Reportorg';
echo $name;
$data ='<?xml version="1.0" encoding="UTF-8"?>
<ReportDefinition xmlns="http://api.direct.yandex.com/v5/reports">
<SelectionCriteria>
<Filter>
<Field>CampaignId</Field>
<Operator>EQUALS</Operator>
<Values>'.$_GET['id_company'].'</Values>
</Filter>
</SelectionCriteria>
<FieldNames>Date</FieldNames>
<FieldNames>CampaignName</FieldNames>
<FieldNames>AdGroupName</FieldNames>
<FieldNames>Ctr</FieldNames>
<FieldNames>ConversionRate</FieldNames>
<FieldNames>CostPerConversion</FieldNames>
<FieldNames>Impressions</FieldNames>
<FieldNames>GoalsRoi</FieldNames>
<FieldNames>Clicks</FieldNames>
<FieldNames>Cost</FieldNames>
<FieldNames>AdNetworkType</FieldNames>
<OrderBy>
<Field>Date</Field>
</OrderBy>
<ReportName>'.$name.'</ReportName>
<ReportType>CUSTOM_REPORT</ReportType>
<DateRangeType>THIS_MONTH</DateRangeType>
<Format>TSV</Format>
<IncludeVAT>NO</IncludeVAT>
<IncludeDiscount>NO</IncludeDiscount>
</ReportDefinition>';
echo "<p></p>";
$tokenYandex = $_SESSION['token'];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.direct.yandex.com/v5/reports/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
//CURLOPT_ENCODING => "",
//CURLOPT_MAXREDIRS => 10,
//CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"Content-type: text/xml",
"accept-language: ru",
"authorization: Bearer ".$tokenYandex,
"processingMode: offline",
"Client-Login: ".$_SESSION['login'],
"returnMoneyInMicros: false"
),
)
);
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$res = curl_exec($curl);
//$res = json_decode($res);
print_r($res);
}
Как можно конвертировать ответ в ассоциативный массив/json?