curl:
function juhecardHttpRequesta($url, $params = false, $ispost = 0,$header=false)
{
$httpInfo = [];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_TIMEOUT, 12);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if($header){
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
}
if ($ispost) {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_URL, $url);
} else {
if ($params) {
curl_setopt($ch, CURLOPT_URL, $url . '?' . $params);
} else {
curl_setopt($ch, CURLOPT_URL, $url);
}
}
$response = curl_exec($ch);
if ($response === FALSE) {
// echo "cURL Error: ".curl_error($ch);
return false;
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$httpInfo = array_merge($httpInfo, curl_getinfo($ch));
curl_close($ch);
return $response;
}
一直使用这个提交一个
juhecardHttpRequesta('http://1.1.1.1/orderapi/updateorderok',['order_id'=>$result['orderNo'],'order_status'=>$orderStatus],1);
一直使用正常,但是今天开始,突然出现问题,echo "cURL Error: ".curl_error($ch);的结果就是 Operation timed out after 12001 milliseconds with 0 bytes received ,但是如果你吧 http://1.1.1.1 修改成域名 ,域名也是解析到 1.1.1.1 上 他就好了
换回 ip 还是出现问题~~~~