tracks/root/push.php

25 lines
639 B
PHP
Raw Normal View History

2020-04-17 10:36:53 -04:00
<?php
2020-04-17 10:38:53 -04:00
# Obtain the JSON payload from an OwnTracks app POSTed via HTTP
# and insert into database table.
2020-04-17 10:36:53 -04:00
2020-04-17 10:38:53 -04:00
header("Content-type: application/json");
2020-04-17 10:36:53 -04:00
2020-04-17 10:38:53 -04:00
$payload = file_get_contents("php://input");
$data = @json_decode($payload, true);
2020-04-17 10:36:53 -04:00
2020-04-17 10:38:53 -04:00
if ($data['_type'] == 'location') {
file_put_contents('toto', serialize($data));
$tst = $data['tst'];
$lat = $data['lat'];
$lon = $data['lon'];
$tid = $data['tid'];
# Convert timestamp to a format suitable for mysql
$dt = date('Y-m-d H:i:s', $tst);
}
2020-04-17 10:36:53 -04:00
2020-04-17 10:38:53 -04:00
$response = array();
# optionally add objects to return to the app (e.g.
# friends or cards)
print json_encode($response);
2020-04-17 10:36:53 -04:00
?>