config = []; } public function SetHeader( $header = null ){ if( !is_array( $header ) ){ $header = array( 'header'=>"Accept-language: ru\r\n" . 'Content-Type: application/json; charset=utf-8;'."\r\n" ); } $this->header = $header; } function Send( $url, $cmd ){ $json = json_encode($cmd); $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_URL, $url); curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 20); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_USERAGENT, 'amicru'); curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $this->header); curl_setopt($curl_handle, CURLOPT_POST, 1); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $json); curl_setopt($curl_handle, CURLOPT_VERBOSE, true); curl_setopt($curl_handle, CURLINFO_HEADER_OUT, true); $query = curl_exec($curl_handle); // echo curl_error($curl_handle); // print_a(curl_getinfo($curl_handle)); $info = curl_getinfo($curl_handle); $this->time = $info['total_time']; curl_close($curl_handle); return $query; } function GetTime(){ return $this->time; } }