Hello!
Form the Website: http://www.wetterstationen.info/for...eckdosen-gesteuert-durch-wetterdaten-per-php/
i get a PHP-Script to login in the Fritzbox and get a Session ID:
After getting the SID - i will be able to switch the DECT Wireless Plug from AVM: https://www.amazon.de/AVM-Intelligente-Steckdose-FRITZ-DECT/dp/B00AQ9E77M/ref=sr_1_1?ie=UTF8&qid=1474630991&sr=8-1&keywords=fritz dect 200
Is it possible to do this in B4A?
Thanks for your HELP!!!
Tom
Form the Website: http://www.wetterstationen.info/for...eckdosen-gesteuert-durch-wetterdaten-per-php/
i get a PHP-Script to login in the Fritzbox and get a Session ID:
B4X:
<?php
// Benutzerspezifische Angaben
$fritzbox_Password = 'passwd';
$ain = '0000000000';
// Challenge bei der Fritz.box holen
$ch = curl_init('http://fritz.box/login_sid.lua');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$login = curl_exec($ch);
$session_status_simplexml = simplexml_load_string($login);
if ($session_status_simplexml->SID != '0000000000000000')
{
$SID = $session_status_simplexml->SID;
}
else
// Session ID errechnen aus Challenge, Passwort und MD5-Verschlüsselung
{
$challenge = $session_status_simplexml->Challenge;
$response = $challenge . '-' . md5(mb_convert_encoding($challenge . '-' . $fritzbox_Password, "UCS-2LE", "UTF-8"));
curl_setopt($ch, CURLOPT_POSTFIELDS, "response={$response}&page=/login_sid.lua");
$sendlogin = curl_exec($ch);
$session_status_simplexml = simplexml_load_string($sendlogin);
if ($session_status_simplexml->SID != '0000000000000000')
{
$SID = $session_status_simplexml->SID;
}
else
{
echo "Fehler: Login fehlgeschlagen";
return;
}
}
curl_close($ch);
// Einschalten (setswitchon)
$import = file_get_contents('https://fritz.box/webservices/homeautoswitch.lua?ain='.$ain. '&switchcmd=setswitchon&sid='.$SID.'');
// Ausschalten (setswitchoff)
/*
$import = file_get_contents('https://fritz.box/webservices/homeautoswitch.lua?ain='.$ain. '&switchcmd=setswitchoff&sid='.$SID.'');
*/
// von der Fritz.box abmelden
$logout = file_get_contents('https://fritz.box/home/home.lua?sid='.$SID.'&logout=1');
?>
After getting the SID - i will be able to switch the DECT Wireless Plug from AVM: https://www.amazon.de/AVM-Intelligente-Steckdose-FRITZ-DECT/dp/B00AQ9E77M/ref=sr_1_1?ie=UTF8&qid=1474630991&sr=8-1&keywords=fritz dect 200
Is it possible to do this in B4A?
Thanks for your HELP!!!
Tom