albeebe / PHP-FindMyiPhone

PHP class to locate, play sounds, and lock iOS devices
Other
79 stars 49 forks source link

Working example #14

Open MrLuit opened 7 years ago

MrLuit commented 7 years ago

It looks like the latest version of this API doesn't work. If someone wants to fix it or still use the Find My iPhone api, here is a working example:

<?php
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$username = "";
$password = "";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://fmipmobile.icloud.com/fmipservice/device/$username/initClient");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$username" . ":" . "$password");

$headers = array();
$headers[] = "Content-Type: application/json; charset=utf-8";
$headers[] = "X-Apple-Find-Api-Ver: 2.0";
$headers[] = "X-Apple-Authscheme: UserIdGuest";
$headers[] = "X-Apple-Realm-Support: 1.0";
$headers[] = "User-Agent: Find iPhone/1.3 MeKit (iPad: iPhone OS/4.2.1)";
$headers[] = "X-Client-Name: iPad";
$headers[] = "X-Client-Uuid: <insert client id here>";
$headers[] = "Accept-Language: en-us";
$headers[] = "Connection: keep-alive";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);

$result = json_decode($result,true)['content'];
foreach($result as $device) {
    print_r($device);
}
?>
tomballgithub commented 7 years ago

Thank You

tomballgithub commented 6 years ago

@MrLuit Any updates or does this still work? I am trying to switch to this method and getting 'Error:SSL certificate problem: unable to get local issuer certificate'. My other method recently stopped working