Topic: Report not correct over API (A bug?)
We are trying to print a report over API according to the documentation here: https://sdk.wialon.com/wiki/en/pro/remo … xec_report
Our report template is based on the trips table. Report contains trip start date, trip end date, trip start location, trip end location, mileage, total km and duration.
In our Wialon Pro system we get correct trip based on chosen date. Via API we get also correct response result BUT only first 4-5 rows. As soon as the system does not have a real address or POI API it just fails to continue showing the trips.
This also means as long as we have street address/POI in our report, its no problems. But when we have coordinates instead of street name/POI than we do not get any more response from API although there are trips that contains addresses/POIs after those rows with coordinates.
Please see our code below.
<?php
// execute report code develop by PHP developer
$loginResponse = get_api_response('core/login', array('user' => 'zeptouser', 'password' => 'zeptopass'));
$userSsid = isset($loginResponse['ssid']) ? $loginResponse['ssid'] : "";
//$_SESSION['USER_SSID'] = current user login session ID
//clean up current result query API
$cleanupResultArr = get_api_response('report/cleanup_result', array(), $userSsid);
//check cleanup result succesfully execute
if (isset($cleanupResultArr['error']) && $cleanupResultArr['error'] == 0) {
//execute report API
$fromTime = strtotime("-2 month", time());
$toTime = strtotime("now");
//6495 is our report resource ID
//7440 is our report object ID
//1 we set report template ID
$execReportArr = get_api_response('report/exec_report', array(
"reportResourceId" => "6495",
"reportTemplateId" => "1",
"reportObjectId" => "7440",
"reportObjectSecId" => "0",
"interval" => array(
"from" => $fromTime,
"to" => $toTime,
"flags" => "0"
),
"tzOffset" => "184749584",
"lang" => "en"), $userSsid);
//get indexTo from exec_report API
$indexTo = $execReportArr['reportResult']['tables'][0]['r'];
//get result row API
$resultArr = get_api_response('report/get_result_rows', array(
"tableIndex" => 0,
"indexFrom" => 0,
"indexTo" => $indexTo), $userSsid);
//Print Final report records
echo "<pre>";print_r($resultArr);
}
//call curl library
function get_api_response($svc, $paramsArray, $ssid = "") {
$paramsJson = is_array($paramsArray) && count($paramsArray) > 0 ? json_encode($paramsArray) : "{}";
$addsession = isset($ssid) && $ssid <> "" ? '&ssid=' . $ssid : "";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://wialonproadress.com/ajax.html');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'svc=' . $svc . '¶ms=' . $paramsJson . $addsession);
$response = curl_exec($ch);
curl_close($ch);
$responseArray = json_decode($response, true);
return $responseArray;
}
?>