1

Report not correct over API (A bug?)

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.

Unfortunately, you are not allowed to view this text



<?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 . '&params=' . $paramsJson . $addsession);
    $response = curl_exec($ch);
    curl_close($ch);
    $responseArray = json_decode($response, true);
    return $responseArray;
}

?>

Unfortunately, you are not allowed to view this text

2

Report not correct over API (A bug?)

Re: Report not correct over API (A bug?)

gpser, your php script is working well. It displays all report results and mileage is equal with your Wialon Pro site.
It seems that problem can occur when you try to display rows with coordinates instead of address like this:

N 56° 0.5654' : E 14° 6.4011'

Such strings contain quotes and need to be slashed to display correctly.

Head of Wialon Local Department
Gurtam
3

Report not correct over API (A bug?)

Re: Report not correct over API (A bug?)

deal, no, the script is not working OK. Have you tested my script? The problem is not the coordinates containing special characters

N 56° 0.5654' : E 14° 6.4011'

The problem is that coordinates never even show up when you print_r() the array.

Please test and you'll see what I mean. Further mileage showing up in the result is not either what is displayed in Wialon Pro Trip Report.
I strongly believe this is a bug.