Last active
August 29, 2015 14:01
-
-
Save dennisheinzen/f1eca2b01ecb65e4d1e1 to your computer and use it in GitHub Desktop.
where.php
This file contains 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 'class.sosumi.php'; | |
header('Content-Type: application/json'); | |
$file = 'location.cache'; | |
if (time() - filemtime($file) > 0) { | |
// older than cache limit | |
$ssm = new Sosumi('xxx@xxx.xxx', 'xxxxxxxx'); | |
$loc = $ssm->locate(6); //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
print_r($ssm->devices);
The devices are now indexed by their GUID as returned by Apple. This lets you reliably query a specific device in case the ordering Apple returns them in changes.
The device's id is its index in the devices array, and also in the device->id property.