Minglarn 0 Posted December 20, 2014 Hi!! Been following this forum for a while and have learned a lot! A couple days ago I thought I could change the settings on my DS-2CD2032-I cam using PHP and XML. Is it possible to do this cause I've tried this code: <?php $xml_data = '<?xml version="1.0" encoding="UTF-8"?> <TextOverlay version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema"> <id>1</id> <enabled>true</enabled> <posX>16</posX> <posY>0</posY> <message>Temp: -0.5C</message> </TextOverlay>'; $URL = 'http://user:passwd@192.168.1.218/Video/inputs/channels/1/overlays/text/1'; $ch = curl_init($URL); curl_setopt($ch, CURLOPT_URL, $URL); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); print_r($output); ?> But no matter how I do it I always get the result as: Invalid Operation What am I doing wrong? //Minglarn... Share this post Link to post Share on other sites
Pshhh 0 Posted March 17, 2015 сорри за некропост ) USE IT <?php $xml_data = '<?xml version="1.0" encoding="UTF-8"?> <TextOverlay version="1.0" xmlns="http://www.hikvision.com/ver10/XMLSchema"> <id>1</id> <enabled>true</enabled> <posX>16</posX> <posY>0</posY> <message>Temp: -0.5C</message> </TextOverlay>'."\r\n"; $user = "admin"; $pass = "12345"; $host = '192.168.1.218'; $path = '/Video/inputs/channels/1/overlays/text/1'; //открываем сокет $fp = @fsockopen("tcp://".$host, 80, $errno, $errstr, 10); if (!$fp) { die($errstr.':'.$errno); } else { $header = "PUT $path HTTP/1.1\r\n"; $header .= "Authorization: Basic ".base64_encode("$user:$pass")."\r\n"; $header .= "User-Agent: php-script\r\n"; $header .= "Host: $host\r\n"; $header .= "Accept: */*\r\n"; $header .= "Content-Length: ".strlen($xml_data)."\r\n\r\n"; //посылаем данные fwrite($fp, $header.$xml_data); $headers=''; //читаем заголовки while ($str = trim(fgets($fp, 4096))) $headers .= "$str\n"; $body=''; //читаем ответ while (!feof($fp)) $body.= fgets($fp, 4096); //закрываем сокет fclose($fp); } //выводим данные echo $headers.'<hr/>'.$body; ?> Share this post Link to post Share on other sites
buellwinkle 0 Posted March 18, 2015 I do it with shell scripts like on an Arduino or Raspberri PI using the curl command with the XML. I had it working to take the temperature using a temp sensor and update the OSD with the temperature. Share this post Link to post Share on other sites
Minglarn 0 Posted March 18, 2015 Thanks for the post! I solved it by using a raspberry and curl. =) Share this post Link to post Share on other sites