Skip to content

Instantly share code, notes, and snippets.

@dennisheinzen
Last active August 29, 2015 14:01
Show Gist options
  • Save dennisheinzen/f1eca2b01ecb65e4d1e1 to your computer and use it in GitHub Desktop.
Save dennisheinzen/f1eca2b01ecb65e4d1e1 to your computer and use it in GitHub Desktop.
where.php
#!/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));
}
?>
@tylerhall
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment