$device, 'submit'=>$state ); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); $ch = curl_init(); if ("nodes"==substr($device,0,5)) { $string="http://isy99/rest/nodes/".rawurlencode(substr($device,-10))."/cmd/$state"; } else { if ($state=="DON") { $state="runThen"; } else { $state="runElse"; } $string="http://isy99/rest/programs/".rawurlencode(substr($device,-4))."/$state"; } curl_setopt($ch, CURLOPT_URL,"$string"); #echo "-$string-"; #exit; #echo "http://isy99/rest/nodes/$device/cmd/$state"; curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, 'admin:admin'); curl_setopt($ch, CURLOPT_HEADER, 0); #curl_setopt($ch,CURLOPT_POST,count($fields)); #curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string); $output = curl_exec($ch); #echo "
";

#print_r($output);

#curl_close($ch);
?>