Я использую скрипт php для экспорта данных из Adobe Analytics. Я выбираю размеры (элементы) и метрики, и это работает. Теперь я пытаюсь добавить детализацию в моем коде и получаю ошибку.
<?php
include_once('/path/SimpleRestClient.php');
// Date
$date = date("Y-m-d",strtotime("-1 days"));
function GetAPIData($method, $data)
{
$username = "XXXXX";
$shared_secret = "XXXXX";
$postURL = "https://api3.omniture.com/admin/1.4/rest/?method=";
// Nonce is a simple unique id to each call to prevent MITM attacks.
$nonce = md5(uniqid(php_uname('n'), true));
// The current timestamp in ISO-8601 format
$nonce_ts = date('c');
/* The Password digest is a concatenation of the nonce, it is timestamp and your password
(from the same location as your username) which runs through SHA1 and then through a base64 encoding */
$digest = base64_encode(sha1($nonce . $nonce_ts . $shared_secret));
$rc = new SimpleRestClient();
$rc -> setOption(CURLOPT_HTTPHEADER, array("X-WSSE: UsernameToken Username=\"$username\", PasswordDigest=\"$digest\", Nonce=\"$nonce\", Created=\"$nonce_ts\""));
//var_dump($o);
$rc -> postWebRequest($postURL .$method, $data);
return $rc;
}
$method = 'Report.Queue';
$data ='
{
"reportDescription":
{
"reportSuiteID":"XXXXX",
"date":"'.$date.'",
"dateGranularity":"day",
"elements":[{"id":"lasttouchchannel"}],
"metrics":[{"id":"visits"},{"id":"instances"},{"id":"event7"}]
}
}';
$rc=GetAPIData($method, $data);
if($rc -> getStatusCode() == 200) // status code 200 is for 'ok'
{
$counter = 0;
do
{
if($counter>0){sleep($sleep = 120);}
$return = GetAPIData('Report.Get', $rc->getWebResponse());
$counter++;
}while($return -> getStatusCode() == 400 && json_decode($return->getWebResponse())->error == 'report_not_ready'); // status code 400 is for 'bad request'
//
$json=json_decode($return->getWebResponse());
foreach ($json->report->data as $el)
{
echo $el->name.": ".$el->counts[0].": ".$el->counts[1].": ".$el->counts[2]."\n";
// Adding the data in the CSV file without overwriting the previous data
//array_push($list, array($el->name, $el->counts[0], ($el->counts[1])/($el->counts[2])));
}
}
else
{
echo "Wrong";
}
/*
$fp = fopen($adobe_file, 'w');
foreach ($list as $fields)
{
// Save the data into a CSV file
fputcsv($fp, $fields);
}
fclose($fp);
*/
?>
Без этой линии "dateGranularity":"day",
код работает.
С этой строкой я получаю ошибку:
Неопределенное свойство: stdClass :: $ counts
Задача ещё не решена.
Других решений пока нет …