You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function user($user)
{
return trim($user);
}
function encodePassword($password)
{
return strtoupper(md5($password));
}
function parseJson($jsonString) {
$jsonString = str_replace('&&&START&&&', '',$jsonString);
$jsonData = json_decode($jsonString, true);
if ($jsonData ===null) return false;
return $jsonData;
}
function clientId()
{
$clientId="";
for ($i=0; $i<7;$i++)
{
$clientId = $clientId.chr(rand(97,122)); // buschstaben a bis z
$clientId = substr($clientId,0,6);
}
return $clientId;
}
Hallo Wolbolar
hier ist der Code zum auslesen von der Token und Map in RRFileFormat
fiel Spaß damit
Einfach $user $password eingaben wie in der APP
Gruß Black-Blade
`<?php
$user ="";
$password="";
$server ="de";
function user($user)
{
return trim($user);
}
function encodePassword($password)
{
return strtoupper(md5($password));
}
function parseJson($jsonString) {
$jsonString = str_replace('&&&START&&&', '',$jsonString);
$jsonData = json_decode($jsonString, true);
if ($jsonData ===null) return false;
}
function clientId()
{
$clientId="";
for ($i=0; $i<7;$i++)
{
$clientId = $clientId.chr(rand(97,122)); // buschstaben a bis z
$clientId = substr($clientId,0,6);
}
return $clientId;
}
function generateSignature($ssecurity,$params,$path)
{
$nonce = random_bytes(16);
$nonce =substr( $nonce,4,12);
$bytes = pack('L',intval(microtime(true)/60));
$nonce=$bytes.$nonce;
$nonce = base64_encode($nonce);
}
function HashHmacSHA256($data, $secret)
{
$test = base64_encode( hash_hmac ( 'sha256' , $data , base64_decode($secret) , true ));
return $test;
}
function login($user,$clientId)
{
$headers = ['Content-Type: application/x-www-form-urlencoded',
'User-Agent: Android-7.1.1-1.0.0-ONEPLUS A3010-136-9D28921C354D7 APP/xiaomi.smarthome APPV/62830',
'Cookie: sdkVersion=accountsdk-18.8.15; userId=' . user($user) . '; deviceId='.clientId()];
$ch = curl_init("https://account.xiaomi.com/pass/serviceLogin?sid=xiaomiio&_json=true");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_TIMEOUT,10);
}
function login_account($user,$password,$clientId,$callback,$qs,$sign)
{
$headers = ['Content-Type: application/x-www-form-urlencoded',
'User-Agent: Android-7.1.1-1.0.0-ONEPLUS A3010-136-9D28921C354D7 APP/xiaomi.smarthome APPV/62830',
'Cookie: sdkVersion=accountsdk-18.8.15; deviceId='.clientId()];
$form = Array ("sid" => "xiaomiio",
"hash"=> encodePassword($password),
"callback"=> $callback,
"qs"=> $qs,
"user"=> user($user),
"_sign"=> $sign,
"_json"=>"true",
}
function login_location($clientId,$location)
{
$ckfile="";
$headers = ['Content-Type: application/x-www-form-urlencoded',
'User-Agent: Android-7.1.1-1.0.0-ONEPLUS A3010-136-9D28921C354D7 APP/xiaomi.smarthome APPV/62830',
'Cookie: sdkVersion=accountsdk-18.8.15; deviceId='.clientId()];
$ch = curl_init($location);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_TIMEOUT,10);
$result=curl_exec ($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
}
function getDeviceStatus ($userid, $serviceToken, $server, $ssecurity)
{
$path ='/home/device_list';
$obj ='{"getVirtualModel":false,"getHuamiDevices":0}';
$headers = ['Content-Type: application/x-www-form-urlencoded',
'x-xiaomi-protocal-flag-cli: PROTOCAL-HTTP2',
'User-Agent: Android-7.1.1-1.0.0-ONEPLUS A3010-136-9D28921C354D7 APP/xiaomi.smarthome APPV/62830',
'Cookie: userId=' . $userid . '; yetAnotherServiceToken=' . $serviceToken . '; serviceToken=' . $serviceToken . '; locale=de_DE; timezone=GMT%2B01%3A00; is_daylight=1; dst_offset=3600000; channel=MI_APP_STORE'];
}
function getMapURL ($userid, $serviceToken, $server, $ssecurity,$did)
{
$path ='/home/getmapfileurl';
$mapName ="robomap%2F".$did."%2F0";
}
$clientId = clientId();
$jsonData = login($user,$clientId);
if ($jsonData === false) return false;
print_r ("logindata\r\n");
print_r ($jsonData);
if(!isset($jsonData['qs'])) return false;
if(!isset($jsonData['callback'])) return false;
if(!isset($jsonData['_sign'])) return false;
$qs= $jsonData["qs"];
$callback= $jsonData["callback"];
$sign= $jsonData["_sign"];
$jsonData = login_account($user,$password,$clientId,$callback,$qs,$sign);
if ($jsonData === false) return false;
print_r ("login_account\r\n");
print_r ($jsonData);
if(!isset($jsonData['ssecurity'])) return false;
if(!isset($jsonData['userId'])) return false;
if(!isset($jsonData['location'])) return false;
$ssecurity = $jsonData["ssecurity"];
$userId = $jsonData["userId"];
$location=$jsonData["location"];
$jsonData = login_location($clientId,$location);
if ($jsonData === false) return false;
print_r ("login_location\r\n");
print_r ($jsonData);
if(!isset($jsonData['userId'])) return false;
if(!isset($jsonData['serviceToken'])) return false;
$userId = $jsonData["userId"];
$serviceToken = $jsonData["serviceToken"];
$jsonData = getDeviceStatus ($userId, $serviceToken, "de", $ssecurity);
if ($jsonData === false) return false;
print_r ("login_location\r\n");
print_r ($jsonData);
if(!isset($jsonData["result"]["list"][0]["did"])) return false;
if(!isset($jsonData["result"]["list"][0]["token"])) return false;
$did =($jsonData["result"]["list"][0]["did"]);
$jsonData =getMapURL($userId, $serviceToken, $server, $ssecurity,$did);
if ($jsonData === false) return false;
print_r ("getMapURL\r\n");
print_r ($jsonData);
if(!isset($jsonData["result"]["url"])) return false;
$url = ($jsonData["result"]["url"]);
print_r($url);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_TIMEOUT,10);
$result=curl_exec ($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
$RRFileFormat = gzdecode($result);
//print_r(bin2hex(gzdecode($result)));
//print_r($result);`
The text was updated successfully, but these errors were encountered: