FindMyiPhone (PHP Klasse) - Sound abspielen, Nachricht anzeigen, Location, ...

Hallo allerseits,

da es ja die letzte Tage etwas Probleme mit einigen PHP Klassen beim Thema „Find my iPhone“ gab, hab ich mich auf die Suche gemacht und eine neue Klasse gefunden und mal ein paar Beispiele zusammengestellt :slight_smile:

Link zum GitHub Repo: Neal/FindMyiPhone · GitHub

PHP CLASS:

<?php

/**
 * FindMyiPhone - A PHP class for interacting with iCloud's Find My iPhone.
 * Copyright (c) 2013 Neal <neal@ineal.me>
 */

class FindMyiPhone {

	private $username;
	private $password;

	public $devices = array();

	private $email_updates = true;

	private $host = 'fmipmobile.icloud.com';
	private $scope;

	private $client_context = array(
		'appName' => 'FindMyiPhone',
		'appVersion' => '3.0',
		'buildVersion' => '376',
		'clientTimestamp' => 0,
		'deviceUDID' => null,
		'inactiveTime' => 1,
		'osVersion' => '7.0.3',
		'productType' => 'iPhone6,1'
	);

	private $server_context = array(
		'callbackIntervalInMS' => 10000,
		'classicUser' => false,
		'clientId' => null,
		'cloudUser' => true,
		'deviceLoadStatus' => '200',
		'enableMapStats' => false,
		'isHSA' => false,
		'lastSessionExtensionTime' => null,
		'macCount' => 0,
		'maxDeviceLoadTime' => 60000,
		'maxLocatingTime' => 90000,
		'preferredLanguage' => 'en-us',
		'prefsUpdateTime' => 0,
		'sessionLifespan' => 900000,
		'timezone' => null,
		'trackInfoCacheDurationInSecs' => 86400,
		'validRegion' => true
	);


	/**
	 * Constructor
	 * Checks requred extensions, sets username/password and gets url host for the user.
	 * @param $username - iCloud Apple ID
	 * @param $password - iCloud Password
	 */
	public function __construct($username, $password) {
		if (!extension_loaded('curl')) {
			throw new FindMyiPhoneException('PHP extension cURL is not loaded.');
		}

		$this->username = $username;
		$this->password = $password;

		$this->init_client();
	}


	/**
	 * Set email updates
	 * If false, requests will request to not send email to the user. (doesn't work on all requests)
	 * True by default. (optional to set)
	 * $param $email_updates - bool
	 */
	public function set_email_updates($email_updates) {
		$this->email_updates = (bool) $email_updates;
	}


	/**
	 * Init Client
	 *
	 */
	private function init_client() {
		$post_data = json_encode(array(
			'clientContext' => $this->client_context
		));

		$headers = $this->parse_curl_headers($this->make_request('initClient', $post_data, true));

		$this->host = $headers['X-Apple-MMe-Host'];
		$this->scope = $headers['X-Apple-MMe-Scope'];

		$this->refresh_client();
	}


	/**
	 * Refresh Client
	 *
	 */
	public function refresh_client() {
		$post_data = json_encode(array(
			'clientContext' => $this->client_context,
			'serverContext' => $this->server_context
		));

		foreach (json_decode($this->make_request('refreshClient', $post_data))->content as $id => $device) {
			$this->devices[$id] = $device;
		}
	}


	/**
	 * Play Sound
	 *
	 */
	public function play_sound($device_id, $subject = 'Find My iPhone Alert') {
		if(!is_string($device_id)) throw new FindMyiPhoneException('Expected $device_id to be a string');
		if(!is_string($subject)) throw new FindMyiPhoneException('Expected $subject to be a string');

		$post_data = json_encode(array(
			'clientContext' => $this->client_context,
			'serverContext' => $this->server_context,
			'device' => $device_id,
			'subject' => $subject
		));

		return json_decode($this->make_request('playSound', $post_data))->content[0]->snd;
	}


	/**
	 * Send Message
	 *
	 */
	public function send_message($device_id, $text, $sound = false, $subject = 'Important Message') {
		if(!is_string($device_id)) throw new FindMyiPhoneException('Expected $device_id to be a string');
		if(!is_string($text)) throw new FindMyiPhoneException('Expected $text to be a string');
		if(!is_bool($sound)) throw new FindMyiPhoneException('Expected $sound to be a bool');
		if(!is_string($subject)) throw new FindMyiPhoneException('Expected $subject to be a string');

		$post_data = json_encode(array(
			'clientContext' => $this->client_context,
			'serverContext' => $this->server_context,
			'device' => $device_id,
			'emailUpdates' => $this->email_updates,
			'sound' => $sound,
			'subject' => $subject,
			'text' => $text,
			'userText' => true
		));

		return json_decode($this->make_request('sendMessage', $post_data))->content[0]->msg;
	}


	/**
	 * Lock Device
	 *
	 */
	public function lost_device($device_id, $passcode, $owner_phone_number = '911', $sound = true, $text = 'This iPhone has been lost. Please call me.') {
		if(!is_string($device_id)) throw new FindMyiPhoneException('Expected $device_id to be a string');
		if(!is_string($passcode)) throw new FindMyiPhoneException('Expected $passcode to be a string');
		if(strlen($passcode) !== 4) throw new FindMyiPhoneException('Expected $passcode to be 4 characters long');
		if(!is_string($owner_phone_number)) throw new FindMyiPhoneException('Expected $owner_phone_number to be a string');
		if(!is_bool($sound)) throw new FindMyiPhoneException('Expected $sound to be a bool');
		if(!is_string($text)) throw new FindMyiPhoneException('Expected $text to be a string');

		$post_data = json_encode(array(
			'clientContext' => $this->client_context,
			'serverContext' => $this->server_context,
			'device' => $device_id,
			'emailUpdates' => $this->email_updates,
			'lostModeEnabled' => true,
			'ownerNbr' => $owner_phone_number,
			'passcode' => $passcode,
			'sound' => $sound,
			'text' => $text,
			'trackingEnabled' => true,
			'userText' => true
		));

		return json_decode($this->make_request('lostDevice', $post_data))->content[0]->lostDevice;
	}


	/**
	 * Notify When Found
	 *
	 */
	public function notify_when_found($device_id, $notify = true) {
		if(!is_string($device_id)) throw new FindMyiPhoneException('Expected $device_id to be a string');
		if(!is_string($notify)) throw new FindMyiPhoneException('Expected $notify to be a boolean');

		$post_data = json_encode(array(
			'clientContext' => $this->client_context,
			'serverContext' => $this->server_context,
			'device' => $device_id,
			'lostModeEnabled' => $notify
		));

		return json_decode($this->make_request('saveLocFoundPref', $post_data))->content[0]->locFoundEnabled;
	}


	/**
	 * Lock and Message
	 *
	 */
	public function lock_and_message($device_id, $passcode, $text, $sound = true, $title = 'Find My iPhone Alert') {
		if(!is_string($device_id)) throw new FindMyiPhoneException('Expected $device_id to be a string');
		if(!is_string($passcode)) throw new FindMyiPhoneException('Expected $passcode to be a string');
		if(strlen($passcode) !== 4) throw new FindMyiPhoneException('Expected $passcode to be 4 characters long');
		if(!is_string($text)) throw new FindMyiPhoneException('Expected $text to be a string');
		if(!is_bool($sound)) throw new FindMyiPhoneException('Expected $sound to be a bool');
		if(!is_string($title)) throw new FindMyiPhoneException('Expected $title to be a string');

		$post_data = json_encode(array(
			'clientContext' => $this->client_context,
			'serverContext' => $this->server_context,
			'device' => $device_id,
			'emailUpdates' => $this->email_updates,
			'passcode' => $passcode,
			'sound' => $sound,
			'text' => $text,
			'title' => $title,
			'userText' => true
		));

		return json_decode($this->make_request('lockAndMessage', $post_data))->content[0]->remoteLock;
	}


	/**
	 * Remote Lock
	 *
	 */
	public function remote_lock($device_id, $passcode) {
		if(!is_string($device_id)) throw new FindMyiPhoneException('Expected $device_id to be a string');
		if(!is_string($passcode)) throw new FindMyiPhoneException('Expected $passcode to be a string');
		if(strlen($passcode) !== 4) throw new FindMyiPhoneException('Expected $passcode to be 4 characters long');

		$post_data = json_encode(array(
			'clientContext' => $this->client_context,
			'serverContext' => $this->server_context,
			'device' => $device_id,
			'emailUpdates' => $this->email_updates,
			'passcode' => $passcode
		));

		return json_decode($this->make_request('remoteLock', $post_data))->content[0]->remoteLock;
	}


	/**
	 * Remote Wipe
	 *
	 */
	public function remote_wipe($device_id, $passcode, $text) {
		if(!is_string($device_id)) throw new FindMyiPhoneException('Expected $device_id to be a string');
		if(!is_string($passcode)) throw new FindMyiPhoneException('Expected $passcode to be a string');
		if(strlen($passcode) !== 4) throw new FindMyiPhoneException('Expected $passcode to be 4 characters long');
		if(!is_string($text)) throw new FindMyiPhoneException('Expected $text to be a string');

		$post_data = json_encode(array(
			'clientContext' => $this->client_context,
			'serverContext' => $this->server_context,
			'device' => $device_id,
			'passcode' => $passcode,
			'text' => $text,
			'emailUpdates' => $this->email_updates
		));

		return json_decode($this->make_request('remoteWipe', $post_data))->content[0]->remoteWipe;
	}


	/**
	 * Locate Device
	 *
	 */
	public function locate_device($device, $timeout = 120) {
		if(!is_integer($device)) throw new FindMyiPhoneException('Expected $device to be an integer');
		if(!isset($this->devices[$device])) $this->refresh_client();

		$start = time();
		while (!$this->devices[$device]->location->locationFinished) {
			if ((time() - $start) > intval($timeout)) {
				throw new FindMyiPhoneException('Failed to locate device! Request timed out.');
			}
			sleep(5);
			$this->refresh_client();
		}

		return $this->devices[$device]->location;
	}


	/**
	 * Make request to the Find My iPhone server.
	 * @param $method - the method
	 * @param $post_data - the POST data
	 * @param $return_headers - also return headers when true
	 * @param $headers - optional headers to send
	 * @return HTTP response
	 */
	private function make_request($method, $post_data, $return_headers = false, $headers = array()) {
		if(!is_string($method)) throw new FindMyiPhoneException('Expected $method to be a string');
		if(!$this->is_json($post_data)) throw new FindMyiPhoneException('Expected $post_data to be json');
		if(!is_array($headers)) throw new FindMyiPhoneException('Expected $headers to be an array');
		if(!is_bool($return_headers)) throw new FindMyiPhoneException('Expected $return_headers to be a bool');
		if(!isset($this->scope)) $this->scope = $this->username;

		array_push($headers, 'Accept-Language: en-us');
		array_push($headers, 'Content-Type: application/json; charset=utf-8');
		array_push($headers, 'X-Apple-Realm-Support: 1.0');
		array_push($headers, 'X-Apple-Find-Api-Ver: 3.0');
		array_push($headers, 'X-Apple-Authscheme: UserIdGuest');

		$curl = curl_init();
		curl_setopt_array($curl, array(
			CURLOPT_TIMEOUT => 9,
			CURLOPT_CONNECTTIMEOUT => 5,
			CURLOPT_SSL_VERIFYPEER => false,
			CURLOPT_FOLLOWLOCATION => true,
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_AUTOREFERER => true,
			CURLOPT_VERBOSE => false,
			CURLOPT_POST => true,
			CURLOPT_POSTFIELDS => $post_data,
			CURLOPT_HTTPHEADER => $headers,
			CURLOPT_HEADER => $return_headers,
			CURLOPT_URL => sprintf("https://%s/fmipservice/device/%s/%s", $this->host, $this->scope, $method),
			CURLOPT_USERPWD => $this->username . ':' . $this->password,
			CURLOPT_USERAGENT => 'FindMyiPhone/376 CFNetwork/672.0.8 Darwin/14.0.0'
		));

		$http_result = curl_exec($curl);
		curl_close($curl);

		return $http_result;
	}


	/**
	 * Parse cURL headers
	 * @param $response - cURL response including the headers
	 * @return array of headers
	 */
	private function parse_curl_headers($response) {
		$headers = array();
		foreach (explode("
", substr($response, 0, strpos($response, "

"))) as $i => $line) {
			if ($i === 0) {
				$headers['http_code'] = $line;
			} else {
				list($key, $value) = explode(': ', $line);
				$headers[$key] = $value;
			}
		}
		return $headers;
	}

	/**
	 * Finds whether a variable is json.
	 */
	private function is_json($var) {
		json_decode($var);
		return (json_last_error() == JSON_ERROR_NONE);
	}
}

class FindMyiPhoneException extends Exception {}

?>

…Skript erstellen mit obigem Inhalt und Skript umbenennen in „findmyiphone.ips.php“

Beispiel-Skript zum Senden einer Nachricht:

<?
require ('findmyiphone.ips.php');

$FindMyiPhone = new FindMyiPhone('BENUTZERNAME', 'PASSWORT');  // iCloud Benutzer/Passwort eingeben
// print_r($FindMyiPhone->devices);  // Devices mit allen Infos auflisten
$device_id = $FindMyiPhone->devices[1]->id;

$text = 'Ich bin eine Nachricht.';

echo 'Sende Nachricht... '."
";
echo ($FindMyiPhone->send_message($device_id, $text, false, 'IP-Symcon')->statusCode == 200) ? '...gesendet!' : '...Fehler!';
echo PHP_EOL;

?>

Beispiel-Skript zum Abspielen eines „Alarm-Ton“:

<?
require ('findmyiphone.ips.php');

$FindMyiPhone = new FindMyiPhone('BENUTZERNAME', 'PASSWORT');  // iCloud Benutzer/Passwort eingeben
// print_r($FindMyiPhone->devices);  // Devices mit allen Infos auflisten
$device_id = $FindMyiPhone->devices[1]->id;

$text = 'IP-Symcon';

echo 'Sound abspielen... '."
";
echo ($FindMyiPhone->play_sound($device_id, $text)->statusCode == 200) ? '...wird abgespielt!' : '...Fehler!';
echo PHP_EOL;

?>

Beispiel-Skript zum Auslesen des Standortes:

<?
require ('findmyiphone.ips.php');

$FindMyiPhone = new FindMyiPhone('BENUTZERNAME', 'PASSWORT');  // iCloud Benutzer/Passwort eingeben
//print_r($FindMyiPhone->devices);  // Devices mit allen Infos auflisten

$longitude = $FindMyiPhone->devices[1]->location->longitude;
$latitude = $FindMyiPhone->devices[1]->location->latitude;

echo "Longitude = ".$longitude;
echo "Latitude = ".$latitude;

?>

Alle (in meinen Augen) sinnvollen Infos in eine Variable schreiben lassen:

<?
require ('findmyiphone.ips.php');

$FindMyiPhone = new FindMyiPhone('BENUTZERNAME', 'PASSWORT'); // iCloud Benutzer/Passwort eingeben
//print_r($FindMyiPhone->devices);  // Alle Devices mit allen Infos auflisten

$device_id = $FindMyiPhone->devices[1]->id;  // durch "devices[1]" mein iPhone ausgewählt


// Location Infos
$location_timeStamp = $FindMyiPhone->devices[1]->location->timeStamp;
$location_positionType = $FindMyiPhone->devices[1]->location->positionType;
$location_horizontalAccuracy = $FindMyiPhone->devices[1]->location->horizontalAccuracy;
$location_longitude = $FindMyiPhone->devices[1]->location->longitude;
$location_latitude = $FindMyiPhone->devices[1]->location->latitude;

// Device Infos
$deviceModel = $FindMyiPhone->devices[1]->deviceModel;
$activationLocked = $FindMyiPhone->devices[1]->activationLocked;
$rawDeviceModel = $FindMyiPhone->devices[1]->rawDeviceModel;
$modelDisplayName = $FindMyiPhone->devices[1]->modelDisplayName;
$deviceDisplayName = $FindMyiPhone->devices[1]->deviceDisplayName;
$locationCapable = $FindMyiPhone->devices[1]->locationCapable;
$batteryLevel = $FindMyiPhone->devices[1]->batteryLevel;
$name = $FindMyiPhone->devices[1]->name;
$passcodeLength = $FindMyiPhone->devices[1]->passcodeLength;
$deviceColor = $FindMyiPhone->devices[1]->deviceColor;
$batteryStatus = $FindMyiPhone->devices[1]->batteryStatus;
$deviceStatus = $FindMyiPhone->devices[1]->deviceStatus;

?>

Liste aller verfügbaren Infos pro Device:

stdClass Object
(
    [canWipeAfterLock] => 1
    [remoteWipe] => 
    [locFoundEnabled] => 
    [location] => stdClass Object
        (
            [timeStamp] => 1420458331310
            [locationType] => 
            [positionType] => Cell
            [horizontalAccuracy] => ******
            [locationFinished] => 
            [isInaccurate] => 
            [longitude] => ***********
            [latitude] => *********
            [isOld] => 
        )

    [deviceModel] => iphone6-*******
    [remoteLock] => 
    [activationLocked] => 1
    [locationEnabled] => 1
    [rawDeviceModel] => iPhone7,2
    [modelDisplayName] => iPhone
    [lostModeCapable] => 1
    [id] => ********
    [deviceDisplayName] => iPhone 6
    [darkWake] => 
    [locationCapable] => 1
    [batteryLevel] => 0.6
    [maxMsgChar] => 160
    [name] => iPhone6Chris
    [features] => stdClass Object
        (
            [CLT] => 
            [CWP] => 
            [WMG] => 1
            [XRM] => 
            [CLK] => 
            [SND] => 1
            [LST] => 1
            [KEY] => 
            [WIP] => 1
            [LOC] => 1
            [LLC] => 
            [MSG] => 1
            [LMG] => 
            [LCK] => 1
            [REM] => 
            [SVP] => 
            [TEU] => 1
            [LKL] => 
            [LKM] => 
            [PIN] => 
            [KPD] => 
        )

    [deviceClass] => iPhone
    [wipeInProgress] => 
    [fmlyShare] => 
    [passcodeLength] => *****
    [mesg] => 
    [isMac] => 
    [snd] => stdClass Object
        (
            [statusCode] => 200
            [createTimestamp] => 1420456410736
        )

    [isLocating] => 1
    [deviceColor] => 3b3b3c-b4b5b9
    [trackingInfo] => 
    [batteryStatus] => NotCharging
    [deviceStatus] => 200
    [wipedTimestamp] => 
    [lockedTimestamp] => 
    [msg] => stdClass Object
        (
            [statusCode] => 200
            [createTimestamp] => 1420456410736
            [userText] => 
            [playSound] => 1
        )

    [lostTimestamp] => 
    [lostModeEnabled] => 
    [thisDevice] => 
    [lostDevice] => 
    [prsId] => 
)

Viel Spaß und Grüße,
Chris

Hi vielen Dank, das du deine Infos hier bereit stellst !!!

So konnte ich in 10 Minuten alles umbauen und erweitern :slight_smile:

Wenn jemand die UNix Zeit umrechnen will:

$akt=$FindMyiPhone->devices[$geraet]->location->timeStamp;
$akt=time($akt);
date("Y-d-m H:i:s", $akt);
$zeitstempel=date("Y-d-m H:i:s", $akt);

$jahr=date("Y", $akt);
$monat=date("m", $akt);
$tag=date("d", $akt);
$uhrz=date("H:i:s", $akt);

Ja sehr cool… vielen Dank dafür!!

Ich hab das letzte Skript mal bissel abgeändert, dann müssen nicht bei allen Werten die ID’s des Gerätes eingetragen werden.
Bei mir wurden ab und an Fehlermeldungen generiert. Die habe ich mit den @-Zeichen unterdrückt.

Danke noch mal,
Peter


<?
require ('findmyiphone.ips.php');

$FindMyiPhone = new FindMyiPhone('BENUTZERNAME', 'PASSWORT'); // iCloud Benutzer/Passwort eingeben
//print_r($FindMyiPhone->devices);  // Alle Devices mit allen Infos auflisten


$device_id = 0; // Geräte ID die abgefragt werden soll

# Ausgabe als array
$device_info = $FindMyiPhone->devices[$device_id];  // Gibt alle Informationen als array aus
//print_r($device_info); // Ausgabe als array

# Ausgabe als einzelne Werte
// Location Infos
@$location_timeStamp = $FindMyiPhone->devices[$device_id]->location->timeStamp;
@$location_positionType = $FindMyiPhone->devices[$device_id]->location->positionType;
@$location_horizontalAccuracy = $FindMyiPhone->devices[$device_id]->location->horizontalAccuracy;
@$location_longitude = $FindMyiPhone->devices[$device_id]->location->longitude;
@$location_latitude = $FindMyiPhone->devices[$device_id]->location->latitude;

// Device Infos
@$deviceModel = $FindMyiPhone->devices[$device_id]->deviceModel;
@$activationLocked = $FindMyiPhone->devices[$device_id]->activationLocked;
@$rawDeviceModel = $FindMyiPhone->devices[$device_id]->rawDeviceModel;
@$modelDisplayName = $FindMyiPhone->devices[$device_id]->modelDisplayName;
@$deviceDisplayName = $FindMyiPhone->devices[$device_id]->deviceDisplayName;
@$locationCapable = $FindMyiPhone->devices[$device_id]->locationCapable;
@$batteryLevel = $FindMyiPhone->devices[$device_id]->batteryLevel;
@$batteryLevel_percent = $batteryLevel*100;
@$name = $FindMyiPhone->devices[$device_id]->name;
@$passcodeLength = $FindMyiPhone->devices[$device_id]->passcodeLength;
@$deviceColor = $FindMyiPhone->devices[$device_id]->deviceColor;
@$batteryStatus = $FindMyiPhone->devices[$device_id]->batteryStatus;
@$deviceStatus = $FindMyiPhone->devices[$device_id]->deviceStatus;

//Testausgabe
echo "$name 
$batteryLevel%
$location_positionType
$location_horizontalAccuracy
Long: $location_longitude
Lat: $location_latitude";

?>

Moin Peter!

Kein Thema und gerne - hab es ja nur rausgesucht, bissi aufbereitet und ein paar Beispiele geschrieben, zum leichteren Einbau :slight_smile: Die eigentliche Arbeit hatte Neal :smiley:

…hier stand Mist :smiley:

Fehlermeldungen? Vom Skript? Von Apple? Was kamen denn da für Meldung? Hatte gestern und auch heute nicht eine beim Testen :confused: Könnte das mit der aktuellen IPS-Beta zusammenhängen (welche Build nutzt du?), da war doch irgendwas mit json?!

Grüße,
Chris

Moin,…

also wenn ich in deinem Skript die devices[1] von 1 in 0 geändert habe, hat sich nix an den Abfragen weiter unten geändert, da da ja überall immer noch die 1 steht:

$device_id = $FindMyiPhone->devices[1]->id;  // durch "devices[1]" mein iPhone ausgewählt

Ich denke aber, das war auch anders von Dir gemeint. Der Code gibt alle Daten für device[1] als array aus und unten hast noch mal alle Daten als Einzelabfrage aufgelistet. Hmm… das hab ich dann falsch interpretiert. War ja nix falsch.

Mit meinem Skript braucht man nicht alle Zeilen ändern, sondern nur die ID des Gerätes eintragen.

Zu den Fehlermeldungen:

Ich habe ein MAC-Mini als Device. Bei abfrage von dem kamen Fehlermeldungen. Diese habe ich mit dem @-Zeichen unterdrückt, ansonsten wird das Skript als Fehlerhaft angezeigt.

Gruß,
Peter

Ach, klar, mein Fehler :smiley: Hatte es falsch verstanden :smiley: Hast natürlich recht, bei dir muss man nur einmal die Zahl ändern für das Device, wenn man es so im gesamten verwendet :slight_smile:

Kannst du bitte nochmal den Fehler ausgeben lassen und mal einen hier posten, würde mich interessieren was da kommt…
Hast du die aktuelle IPS-Beta-Build oder welche Version hast du? Im Beta-Bereich ist ja grad irgendwas gewesen mit json und Fehler-Ausgaben. Nur um sicher zu gehen, ob hier alles korrekt ist.

MfG,
Chris

Klar…

Das kommt bei Abfrage meines MAC Minis ohne die @-Zeichen:


Notice:  Undefined index: X-Apple-MMe-Host in C:\IP-Symcon\scripts\findmyiphone.ips.php on line 93

Notice:  Undefined index: X-Apple-MMe-Scope in C:\IP-Symcon\scripts\findmyiphone.ips.php on line 94

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\findmyiphone.ips.php on line 110

Warning:  Invalid argument supplied for foreach() in C:\IP-Symcon\scripts\findmyiphone.ips.php on line 110

Notice:  Undefined offset: 0 in C:\IP-Symcon\scripts\29305.ips.php on line 8

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 14

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 14

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 14

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 15

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 15

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 15

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 16

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 16

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 16

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 17

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 17

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 17

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 18

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 18

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 18

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 21

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 21

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 22

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 22

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 23

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 23

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 24

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 24

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 25

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 25

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 26

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 26

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 27

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 27

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 28

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 28

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 29

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 29

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 30

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 30

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 31

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 31

Notice:  Undefined offset: 2 in C:\IP-Symcon\scripts\29305.ips.php on line 32

Notice:  Trying to get property of non-object in C:\IP-Symcon\scripts\29305.ips.php on line 32

Kann es mir nicht erklären, bei mir kommen die Fehler nicht. Auch nicht wenn ich dein Skript nehme. Keine Ahnung woran das liegt…
…hab es mal im Beta-Thread gepostet, wo ich Ähnlichkeiten sehe…

Oder kann es vlt. sein, dass die Variablen einfach nicht gefüllt sind bei einem MAC Computer??? Oder vlt. sogar gar nicht vorhanden??? Wenn du dir das komplett mit „print_r($FindMyiPhone->devices);“ ausgeben lässt, sind die Dinger dann mit Inhalt oder leer? Weil wenn die leer sind oder gar nicht vorhanden, dann könnte ich es mir erklären, dass da was durcheinander kommt oder einfach nicht richtig abgefangen wird… Bzw. was nicht da ist kann er auch nicht anzeigen und dann passen die Fehler…

Grüße,
Chris

Hmmm…der timestamp gibt aber nur die Zeit aus, wann das Skript den Apple Server anfragt, und nicht, wann das iPhone erreicht wurde.

Ich habe mein iphone jetzt seit 6 Minuten aus, und die query zeigt jedes mal

a) im timestamp die aktuelle Uhrzeit
b) [locationFinished] => 1 (müsste das nicht leer sein?)
c) [isInaccurate] => (müsste hier nicht eine „1“ stehen?)
d) [isOld] => (Oder wenigstens hier eine „1“?)

Ist das bei Euch auch so? Ich suche sowas wie: LastFix…

[EDIT]
Liegt an der hier geposteten Zeitfunktion (Umrechnung Unixtimestamp). Die wirft immer die aktuelle Zeit.

@drapple: Kannst du bitte dein Skript überarbeiten in deinem Post? Damit es korrekt funktioniert?! :slight_smile: (siehe den Beitrag 9 von wupperi)

Grüße,
Chris

Bin mir auch nicht sicher, dass der Apple timestamp der Unix timestamp ist.
Normalerweise kann ich einen Unix timestamp simple mit „date“:


$stamp = $location_timeStamp;
echo date("d.m.Y\ H:i:s", $stamp);

in ein normales Format wandeln.

Mein Timestamp ist gerade

1420556115307

und die funktion date wirft aus:

03.11.1935 11:58:51

D.h. mit 5h Zeitverschiebung könnte es passen (Minuten/Sekunden scheinen zu stimmen - Aber Ostküste USA wären 6h, Los Angeles 9h und UTC 1h…) aber das Datum stimmt mal gar nicht :smiley:

So, irgendwie hat der Apple timestring hinten 3 Stellen zuviel.

Wenn man


$stamp = substr($location_timeStamp,0,10);
echo date("d.m.Y\ H:i:s", $stamp);

nutzt, also den timestamp auf die ersten 10 Zeichen begrenzt, dann passts.

Hallo Leute,

tolles Skript, Dank für das Posten.

Woher weiß ich welche IDevice-D welchem Gerät zugeordnet ist?

Joachim

Try and error, einfach durchprobieren und schauen welcher device name beimwelcher ID angezeigt wird.

Entweder paar Zahlen durchprobieren, oder mit diesem Skript ALLE Devices und Infos ausgeben lassen. Dann solltest spätestens am Namen erkennen, welches dein richtiges Device ist :slight_smile: Darüber sollte dann im Array eine Zahl zu sehen sein…1,2,3,4,5,… :wink:

<?
require ('findmyiphone.ips.php');

$FindMyiPhone = new FindMyiPhone('BENUTZERNAME', 'PASSWORT');  // iCloud Benutzer/Passwort eingeben
print_r($FindMyiPhone->devices);  // ALLE Devices mit ALLEN Infos auflisten
?>

Grüße,
Chris

Vielen Dank erst einmal für die Antworten.

Bekomme ich sicher auch über Versuche heraus, aber ist die Zuordnung den konstant oder ändert sich diese?

Joachim

Gute Frage…ehrlich gesagt keine Ahnung, ob die IDs sich ändern. Aber ich würde mal behaupten, dass diese sich nur ändert, wenn du ein Gerät löscht oder ein neues Gerät hinzufügst. Denn meine Liste hat sich von gestern auf heute nicht geändert und die IDs sind noch unverändert.
Selbst wenn neue Geräte dazu kommen oder welche rausgenommen werden, dann werden wohl verbleibende Geräte nicht geändert, sondern nur die anderen…weißte wie ich mein? Aber Garantie gibts keine :slight_smile: Alles was wir zu der Class wissen steht hier im Thread :slight_smile:

Grüße,
Chris

Hallo,
wie bekomme ich mein Iphone in Google Maps angezeigt?

hab es so versucht

<?
require ('findmyiphone.ips.php');
$map = 15936 /*[Skripte\FindMyIphone\map]*/  ;

$FindMyiPhone = new FindMyiPhone('Benutzer', 'PW');


$longitude = $FindMyiPhone->devices[2]->location->longitude;
$latitude = $FindMyiPhone->devices[2]->location->latitude;
$lola = "$longitude,$latitude";


$maps="http://maps.google.de/maps?hl=de&q=$lola&ie=UTF8&t=&z=14&output=embed";

SetValueString($map , "<iframe src=$maps border=\"0\" frameborder=\"0\" style=\"top:0pt; bottom:0pt; left:0pt; right:0pt; width:100%; height:1000px;\"/></iframe>");

?>

aber bekomme immer nur das angezeigt

Denke Du hast im Google String lat und lon in der Reihenfolge vertauscht.

Danke, so funktionierts!