Fritzbox: wird Gespräch geführt

Hallo
hier eine PHPscript zur Abfrage ob ein Telefonat geführt.
In meinem Fall sollte ein Neustart der Fritzbox erfolgen wenn gerade kein Telefonat geführt wird.


<?php
if(!fritz('isTelefonCall')){
		fritz('reset');
		
 }
function fritz($mod=''){

$action=false;
if($mod=='reset'){
	$mods='igdupnp/control/WANIPConn1';
	$scheme='urn:schemas-upnp-org:service:WANIPConnection:1';
	$action = 'ForceTermination';
	return setAction($action,$mods, $scheme);
}
if($mod=='isTelefonCall'){
	$mods='upnp/control/x_contact';
	$scheme='urn:dslforum-org:service:X_AVM-DE_OnTel:1';
	$action = 'GetCallList';
	
	$t= setAction($action,$mods, $scheme).'&days=1';
	
	$response_xml_data = file_get_contents($t);
 if($response_xml_data){


 $data = simplexml_load_string($response_xml_data,"SimpleXMLElement", LIBXML_NOCDATA);
 $json = json_encode($data);
$array = json_decode($json,TRUE);
 foreach($array['Call'] as $k=>$v){
	 #print_r($v);
	 if($v['Type']>=9){return 1;}
 }  
 }
}


}

function setAction ($action,$mod, $scheme){
		$fritzbox_Adresse = 'fritz.box';
$fritzbox_Adresse = '192.168.178.1';
$fritzbox_Username = '';
$fritzbox_Password = 'passwort';
if($action){
$client = new SoapClient(
    null,
    array(
       
		'location'   => 'http://'.$fritzbox_Adresse.':49000/'.$mod,
        'uri'=> $scheme,
        'noroot'     => True,
        'login'      => $fritzbox_Username,
        'password'   => $fritzbox_Password,
        'trace'      => True,
        'exceptions' => 0
    )
);


$argument = 'NewSessionID';

$SID = '0000000000000000';
$direction_in_value = $SID;

//$result = $client->{$action}(new SoapParam($direction_in_value, $argument));
$result = $client->{$action}();

if(is_soap_fault($result))
{
 print_r(" Fehlercode: $result->faultcode | Fehlerstring:
         $result->faultstring");
}
else
{
} 

return ($result);
}
	
}
?>