Created
July 14, 2013 10:30
-
-
Save m4p/5993873 to your computer and use it in GitHub Desktop.
Backend for map.af/api.location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?PHP | |
require '/var/www/offsite/class.sosumi.php'; | |
header('Content-Type: application/json'); | |
$file = '/var/www/offsite/location.cache'; | |
if (time() - filemtime($file) > 5*60) { | |
// older than cache limit | |
$ssm = new Sosumi('your_username', 'your_password'); | |
$loc = $ssm->locate(5); //Devicenumber found by try&error | |
if(strlen($loc['latitude'])) | |
{ | |
$json = "{\"latitude\":\"".$loc['latitude']. "\", \"longitude\":\"" . $loc['longitude'] . "\", \"accuracy\":\"" . $loc['accuracy'] . "\", \"timestamp\":\"" . $loc['timestamp'] . "\", \"serverepoch\":\"" . date("U") . "\"}"; | |
print($json); | |
file_put_contents($file, $json); | |
} | |
} else { | |
print(file_get_contents($file)); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment