Da muss ja ein Problem sein bei mir.
Ich muss doch nur ne IP eingeben und den Rest holt sich das Skript oder habe ich da einen Denkfehler?
$tv_ip_ID IP vom TV
$my_device_ID ???
$my_nick_ID ???
$my_uuid_ID ???
$TVCode_ID Code wenn Anmeldung erfolgreich
$Cookie_ID Coockie ID der TV Verbindung nach Anmeldung
<?
$Parent = IPS_GetParent($_IPS['SELF']);
$ParentModul = IPS_GetObject($Parent);
// Variablen identifizieren
$tv_ip_ID = IPS_GetObjectIDByName('Tv-IP', IPS_GetParent($_IPS['SELF']));
$my_device_ID = IPS_GetObjectIDByName('my_device', IPS_GetParent($_IPS['SELF']));
$my_nick_ID = IPS_GetObjectIDByName('my_nick', IPS_GetParent($_IPS['SELF']));
$my_uuid_ID = IPS_GetObjectIDByName('my_uuid', IPS_GetParent($_IPS['SELF']));
$TVCode_ID = IPS_GetObjectIDByName('TVCode', IPS_GetParent($_IPS['SELF']));
$Cookie_ID = IPS_GetObjectIDByName('Cookie', IPS_GetParent($_IPS['SELF']));
// IPS Werte auslesen
// IPS Werte auslesen
$tv_ip=getValueString($tv_ip_ID);
$my_device=GetValueString ($my_device_ID);
$my_nick=GetValueString ($my_nick_ID );
$my_uuid=GetValueString ($my_uuid_ID );
$TVCode=GetValueString ($TVCode_ID );
$cookie= getValueString($Cookie_ID);
# use only A-Z a-z 0-9 for device. Probably. Havent checked.
// Start anlernen
$url ='/sony/accessControl';
$data='{"method":"actRegister","params":[{"clientid":"'.$my_nick.':'.$my_uuid.'","nickname":"'.$my_nick.' ('.$my_device.')","level":"private"},[{"value":"yes","function":"WOL"}]],"id":8,"version":"1.0"}';
$ch = curl_init('http://'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
$ausgabe = curl_exec($ch);
curl_close($ch);
//echo $ausgabe.chr(10);
// Hier auf Eingabe vom Code warten (WebFront)
$tv_key ='Neu';
SetValueString ($TVCode_ID , $tv_key);
$i = 0;
while( $tv_key === 'Neu')
{
$tv_key=GetValueString ($TVCode_ID);
// echo $tv_key;
IPS_sleep(1000);
$i++;
if( $i == 40 )break;
}
// Key senden
$tv_key=GetValueString ($TVCode_ID);
//echo $tv_key;
$tv_key=':'.$tv_key;
$tv_challenge = base64_encode($tv_key);
$tv_auth_header='Authorization: Basic '.$tv_challenge;
//echo $tv_auth_header.chr(10);
$headers = array();
$headers[]=$tv_auth_header;
$ch = curl_init('http://'. $tv_ip . $url);
curl_setopt($ch, CURLOPT_USERAGENT,"curl 7.26.0");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, true);
$ausgabe = curl_exec($ch);
//echo $ausgabe.chr(10);
curl_close($ch);
list($headers, $response) = explode("
", $ausgabe, 2);
$headers = explode("
", $headers);
foreach($headers as $header) {
if (stripos($header, 'Set-Cookie:') !== false) {
// echo $header.chr(10);
$header = substr($header,0,strpos($header,";"));
$auth = strstr($header, "a");
// echo $auth;
SetValueString ($Cookie_ID , $auth );
}
}
?>