Hello Team,
First of thanks for such a great software.
I want to post data from traccar to my own database.
for this reason i am using forward.url , i am able to hit given url but not able to get data posted by traccar.
Below are changes done in traccar.xml.
<entry key='forward.enable'>true</entry>
<entry key='forward.url'>http://localhost:8081/gps/positions.php?id={uniqueId}&code=0x0000&gprmc={gprmc}</entry>
<entry key='event.enable'>true</entry>
<entry key='event.forward.header'> Content-Type: application/json; charset=utf-8 </entry>
at server side i have done below code which accepts json request and writes to a file.
<?php
$log_dir = 'C:\xampp\htdocs\gps\tmp\test.txt';
$json_str = file_get_contents('php://input');
$fp=fopen( $log_dir, "a" );
fputs($fp, "jsonobj:".$json_str."\r\n");
fclose($fp);
?>
But i am getting blank request.
can you please let me know where i am getting wrong.
Well, for event forwarding you haven't provided any URL, so it won't work.
As for position forwarding, it doesn't include any body. As you can see, all data is in query parameters.
Thanks Anton,
Now i am able to receive position logs.
But i am not receiving logs for devices which are not registered in traccar.
I have installed traccar client app on my android phone , when i am starting service its showing send failed as that device is not registered in traccar web.
is it important to register device in traccar?
It is necessary, but there is an option to register devices automatically.
can you please let me know , how can i register devices automatically.
Thanks for sharing document link . i have found solution thanks.
Hello Team,
First of thanks for such a great software.
I want to post data from traccar to my own database.
for this reason i am using forward.url , i am able to hit given url but not able to get data posted by traccar.
Below are changes done in traccar.xml.
<entry key='forward.enable'>true</entry> <entry key='forward.url'>http://localhost:8081/gps/positions.php?id={uniqueId}&code=0x0000&gprmc={gprmc}</entry> <entry key='event.enable'>true</entry> <entry key='event.forward.header'> Content-Type: application/json; charset=utf-8 </entry>
at server side i have done below code which accepts json request and writes to a file.
<?php $log_dir = 'C:\xampp\htdocs\gps\tmp\test.txt'; #Get JSON as a string $json_str = file_get_contents('php://input'); $fp=fopen( $log_dir, "a" ); fputs($fp, "jsonobj:".$json_str."\r\n"); fclose($fp); ?>
But i am getting blank request.
can you please let me know where i am getting wrong.