public static function execute($url, $method, $postData = null, $options = array(), &$errors = array())
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 150);
//设置cURL允许执行的最长秒数
//https请求 不验证证书和host
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
if (strtolower($method) === 'post') {
curl_setopt($ch, CURLOPT_POST, true);
if ($postData !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
}
}
if (!empty($options)) {
curl_setopt_array($ch, $options);
}
if (!($output = curl_exec($ch))) {
$errors = array('errno' => curl_errno($ch), 'error' => curl_error($ch)) + curl_getinfo($ch);
}
curl_close($ch);
return $output;
}