Body->addChild($root, null, SOAP_BASE); foreach ($keys as $key => $value) { $root->addChild($key, $value); } return $base->asXML(); } function soap_http($post, $headers = array()) { $curl = curl_init(SOAP_URL); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_POSTFIELDS, $post); $xml = simplexml_load_string(curl_exec($curl)); if ($xml !== false) $xml = $xml->children('soap', true)->children(SOAP_BASE); curl_close($curl); return $xml; } function soap($command, $body = array()) { static $login, $private; if (!$login) { $login = soap_http(soap_xml('Login', array('Action' => 'request', 'Username' => SOAP_USER, 'LoginPassword' => '', 'Captcha' => '')), array('SOAPAction: "' . SOAP_BASE . 'Login"'))->LoginResponse; if (!$login) return false; $private = soap_hmac($login->PublicKey . SOAP_PASS, $login->Challenge); soap('Login', array('Action' => 'login', 'Username' => SOAP_USER, 'LoginPassword' => soap_hmac($private, $login->Challenge), 'Captcha' => '')); } $action = '"' . SOAP_BASE . $command . '"'; $time = time() * 1000; return soap_http(soap_xml($command, $body), array('SOAPAction: ' . $action, 'Cookie: uid=' . $login->Cookie, 'HNAP_AUTH: ' . soap_hmac($private, $time . $action) . ' ' . $time))->{$command . 'Response'}; } // Get the list of all commands // print_r(soap('GetDeviceSettings')->SOAPActions->string); // Get connected devices // print_r(soap('GetClientInfo')->ClientInfoLists); // foreach (soap('GetClientInfo')->ClientInfoLists->ClientInfo as $client) { ?>