Skip to content

Instantly share code, notes, and snippets.

@moneeb777
Last active May 12, 2016 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moneeb777/d5c1ce26d68273e59ae2c10184e5bdb2 to your computer and use it in GitHub Desktop.
Save moneeb777/d5c1ce26d68273e59ae2c10184e5bdb2 to your computer and use it in GitHub Desktop.
to get POST data from AndroidLocation application
<?php
// overwrite current location to myCurrentLocation.json
$myfile = fopen("resources/myCurrentLocation.json", "w");
$time = $_POST["time"];
$lat = $_POST["lat"];
$lng = $_POST["lng"];
$arr = array('time' => $time, 'lat' => $lat, 'lng' => $lng);
fwrite($myfile, json_encode($arr));
fwrite($myfile, "\n");
fclose($myfile);
// append current location to historical record
$myfile = fopen("resources/myLocationRecord.json", "a");
$arr = array('time' => $time, 'lat' => $lat, 'lng' => $lng);
fwrite($myfile, json_encode($arr));
fwrite($myfile, "\n");
fclose($myfile);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment