Don't know where to copy the function, haha
Public function http ($url, $params, $method = ' GET ', $header = Array (), $multi = False) {
$opts = Array (
Curlopt_timeout = 30,
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);
Break
Case ' POST ':
Determine whether to transfer files
$params = $multi? $params: Http_build_query ($params);
$opts [Curlopt_url] = $url;
$opts [Curlopt_post] = 1;
$opts [Curlopt_postfields] = $params;
Break
Default
throw new Exception (' Unsupported request mode! ‘);
}
/* Initialize and perform 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 (' request error: '. $error);
return $data;
}
Post call
$this-http ($url, $requestData, ' POST ', Array ("Content-type:application/x-www-form-urlencoded;charset=utf-8")) ;
Get call
$this-http ($url, $val, ' GET ', Array ("content-type:text/html; Charset=utf-8 "));
thinkphp POST and GET pass values