public static function newCurl($url, $data = array(), $timeout = 5)
{
$ch = curl_init();
if (is_array($data) && $data) {
$formdata = http_build_query($data);
$formdata = urldecode($formdata); // 处理中文加密
// dump($formdata);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formdata);
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$formdata = urldecode($formdata); // 处理中文加密