How to get JSON data for reports summary and trips

Md Azharuddin7 years ago

Hello
I am trying to get json data with php CURL request when i am giveing this MY_URL/api/reports/trips?deviceId=200&from=2018-01-07T18%3A30%3A00.000Z&to=2018-01-08T05%3A59%3A47.000Z in CURL it is not giving any response but when i open this url in browser it asks me to download report
How can i get json data from api for trips and summary

Anton Tananaev7 years ago

It has been discussed many times before. You need to provide Accept header in your request.

imarinkovic7 years ago

Hi Md Azharuddin

I'm using this:

$hoy = date("c",strtotime("today"));
$ayer = date("c",strtotime("yesterday"));
$gid=9; //Grupo de Moviles
$login = 'xxxx';
$password = 'yyyyyyy';
$url = 'http://<server_replace_here>/api/reports/summary?groupId='.$gid.'&from='.$ayer.'&to='.$hoy;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
$result = curl_exec($ch);
curl_close($ch);
$a_summary = (json_decode($result,true));

I hope this work for you too.

Anton Tananaev7 years ago

I don't see any Accept header. It might work randomly, but it's not guaranteed to work.

Md Azharuddin7 years ago

Thank you So much Anton and imarinkovic