forked from albeebe/PHP-FindMyiPhone
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
40 lines (30 loc) · 1.17 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?PHP
// This will prevent any errors that occur from potentially displaying your username/password
error_reporting(0);
// This should properly display device names that contain special characters
header("Content-type: text/html; charset=utf-8");
// Include the FindMyiPhone class
include ("class.findmyiphone.php");
// This is where we log in to iCloud
try {
$fmi = new FindMyiPhone("username_goes_here", "password_goes_here");
} catch (Exception $e) {
print "Error: ".$e->getMessage();
exit;
}
// This will print out all the devices on your account so you can grab the device IDs
$fmi->printDevices();
// Find a device that is reporting its location and attempt to get its current location
foreach ($fmi->devices as $device) {
if ($device->location->timestamp != "") {
// Locate the device
$location = $fmi->locate($device->ID);
print "Device <B>".$device->ID."</B> is located at <I>".$location->latitude.", ".$location->longitude."</I>";
// Play a sound on the device
$fmi->playSound($device->ID, "You've been located!");
// Lock the device
//$fmi->lostMode($device->ID, "You got locked out", "555-555-5555");
break;
}
}
?>