/** * Send HTTP request method, currently only support curl Send request * @param string $url request URL * @param array $params request parameter * @param St Ring $method Request Method Get/post * @return Array $data response data*/ protected functionhttp$url,$params,$method= ' GET ',$header=Array(),$multi=false) { $opts=Array(curlopt_timeout = Curlopt_returntransfer = 1, Curlopt_ssl_verifypeer =false, Curlopt_ssl_verifyhost =false, Curlopt_httpheader =$header); /*set specific parameters based on request type*/ Switch(Strtoupper($method)) { Case' GET ':$opts[Curlopt_url] =$url. ' & '.Http_build_query($params); Dump ($opts[Curlopt_url]); Break; Case' POST '://determine whether to transfer files $params=$multi?$params:Http_build_query($params); $opts[Curlopt_url] =$url; Dump ($opts[Curlopt_url]); $opts[Curlopt_post] = 1; $opts[Curlopt_postfields] =$params; Break; default:Throw New Exception(' Unsupported request mode! ‘); } /*initializing and executing a curl request*/ $ch=Curl_init (); Curl_setopt_array ($ch,$opts); $data= Curl_exec ($ch); $error= Curl_error ($ch); Curl_close ($ch); if($error) Throw New Exception(' The request has an error: '.$error); return $data; }