I just want to share the function reportRoute for the traccar-api-php simply add it in the traccar class.
public static function reportRoute($deviceId,$groupId,$from,$to,$cookie) {
$data='deviceId='.$deviceId.'&groupId='.$groupId.'&from='.$from.'&to='.$to;
return self::curl('/api/reports/route?'.$data,'GET',$cookie ,'',array());
}
To call it the DateTime format should be in ISO format, here is the way to transform a DateTime string to an ISO formatted object required by the traccar API.
//The DateTimes interval you want to get the route ;
$from_str = '2017-07-25 00:00:10';
$to_str = '2017-07-25 10:10:10';
//Transforming them in a <code>DateTime</code> Object
$from_obj = new DateTime($from_str);
$to_obj = new DateTime($to_str);
//Transforming it in <code>ISO</code> format (required by the Traccar API)
$from_iso = substr($from_obj->format(DateTime::ATOM),0,-6).'.000Z';
$to_iso = substr($to_obj->format(DateTime::ATOM),0,-6).'.000Z';
And the simply call the reportRoute function ;
$route=traccar::reportRoute($deviceId,$groupId,$from_iso,$to_iso,$cookie);
echo $route->response;
I just want to share the function reportRoute for the traccar-api-php simply add it in the traccar class.
To call it the DateTime format should be in ISO format, here is the way to transform a DateTime string to an ISO formatted object required by the traccar API.
And the simply call the reportRoute function ;