Open NathanWilcox opened 7 years ago
Run the script above to find all devices. Then under ID column, copy the ID and then place into the code below where it says "device_id".
<?php
include ("class.findmyiphone.php");
$fmi = new FindMyiPhone("username", "password");
$location = $fmi->locate("device_id", 30);
$longitude = $location->longitude;
$latitude = $location->latitude
?>
Hi @philarkwright
I've done the above but encountered the following error:
PHP Notice: Undefined offset: 1 in /etc/openhab2/scripts/class.findmyiphone.php on line 261 PHP Notice: Undefined offset: 1 in /etc/openhab2/scripts/class.findmyiphone.php on line 261
The section this refers to in my class.findmyiphone.php looks like this:
curl_setopt($ch, CURLOPT_HTTPHEADER, $arrHeaders); $response = curl_exec($ch); $info = curl_getinfo($ch); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $responseBody = substr($response, $header_size); $headers = array(); foreach (explode("\r\n", substr($response, 0, $header_size)) as $i => $line) { if ($i === 0) $headers['http_code'] = $info["http_code"]; else { list ($key, $value) = explode(': ', $line); if (strlen($key) > 0) $headers[$key] = $value; }
With line 261 actually being:
list ($key, $value) = explode(': ', $line);
Any ideas on this?
Hi,
Where in the following code can I enter specific device id to return the location?
I would like to only request location of a specific device not all of them.
Thanks