So basically this is a script made by somebody, I can run the program but can't receive POST by Android in my php. According to the maker :
This is an Android app I threw together in a few hours to do periodic GPS location tracking on a phone and send the GPS coordinates to an HTTP server.
Enter a URL that accepts POST requests, choose a poll interval, and tap "Enable Tracking". The Android location manager will return a GPS location every so often around that interval (it is not exact) and the information will be POSTed to your URL.
The POSTed parameters are a locations array, each element being a hash including time (a Unix Timestamp from the Location service), latitude and longitude (two float values of arbitrary precision), and speed in meters per second.
I already tried some method in PHP such as :
$locations = $_REQUEST['locations']; // Get all POST arrays
$i = 2; // Choose first locations array
// Now you can access single fields with:
$time = $locations[i]['time'];
$latitude = $locations[i]['latitude'];
$longitude = $locations[i]['longitude'];
$speed = $locations[i]['speed'];
$sogilat = $_POST['latitude'];
$sogilong = $_POST['longitude'];
$data = json_decode($_POST['latitude']);
echo $data->latitude;
but no has no luck, attached some part of the code :
private void sendLocation(Location location) {
List<NameValuePair> pairs = new ArrayList<NameValuePair>(2);
pairs.add(new BasicNameValuePair("time",
String.valueOf(location.getTime())));
pairs.add(new BasicNameValuePair("latitude",
String.valueOf(location.getLatitude())));
pairs.add(new BasicNameValuePair("longitude",
String.valueOf(location.getLongitude())));
pairs.add(new BasicNameValuePair("speed",
String.valueOf(location.getSpeed())));
/* push these pairs onto the queue, and only run the poster if another
* one isn't running already (if it is, it will keep running through
* the queue until it's empty) */
updateLock.writeLock().lock();
mUpdates.add(pairs);
int size = service.getUpdatesSize();
cacheUpdates();
updateLock.writeLock().unlock();
logText("location " +
(new DecimalFormat("#.######").format(location.getLatitude())) +
", " +
(new DecimalFormat("#.######").format(location.getLongitude())) +
(size <= 1 ? "" : " (" + size + " queued)"));
if (httpPoster == null ||
httpPoster.getStatus() == AsyncTask.Status.FINISHED)
(httpPoster = new HttpPoster()).execute();
}
Full script can be found here
Please Help, thanks before....