$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); $result=curl_exec($ch); return $result; } /** * post data to vz middleware * param 1: vzurl - middleware url of volkszaehler * param 2: channel uuid * param 3: value to post */ function post2vz($vzurl,$cuuid,$value,$debug=false) { // post data to middleware according to: // http://wiki.volkszaehler.org/development/api/reference // adapt timestamp to volkszaehler conventions $timestamp=time()*1000; # first $posturl=$vzurl."/".$cuuid.".json"; $fields=array("ts"=>$timestamp,"value" => $value ); $presult=postUrl($posturl,$fields); if ($debug) { echo $presult; } } /** * check that option $opt is available in $options * return the value if available */ function checkoption($opt,$options) { if (array_key_exists($opt,$options)) return $options[$opt]; else die("option $opt missing!\n"); } ?>