Private functionHttp_get_data ($url){ $ch= Curl_init ($url) ; curl_setopt ($ch, Curlopt_returntransfer,true) ;//Get Data backcurl_setopt ($ch, Curlopt_binarytransfer,true) ;//gets the data back when Curlopt_returntransfer is enabled $data= Curl_exec ($ch) ; if(Curl_errno ($ch)) { $this->errorlogger (' Curl get falied. Error Info: '. Curl_error ($ch)); return $ch; } curl_close ($ch) ; return $data; } Public functionHttp_post_data ($url,$data _string) { $ch=Curl_init (); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_url,$url); curl_setopt ($ch, Curlopt_postfields,$data _string); curl_setopt ($ch, Curlopt_httpheader,Array( ' Content-type:application/json; Charset=utf-8 ', ' content-length: '.strlen($data _string)) ); Ob_start(); $ret= Curl_exec ($ch); if(Curl_errno ($ch)) { //$this->errorlogger (' Curl post falied. Error Info: '. Curl_error ($ch)); } $return _content=ob_get_contents(); Ob_end_clean(); return $return _content; }
Send data:
$arr=array(' filed ' = ' * ', ' where ' = =array(' accountun ' = =$uname, ' Accountpwd ' =$upwd)); $rs $this->http_post_data ($url,json_encode($arr));
Get Data:
$this Json_decode ($GLOBALS[' Http_raw_post_data '],true);
Http_post_data How to get the data sent