php请求接口两次,php curl post请求执行一次curl_exce 请求的接口确执行两次
1、php curl post請求接口,打印日志執(zhí)行了一次curl_exce,但是請求的接口卻重復執(zhí)行兩次.
2、代碼:
$ch = curl_init();
if(false === $ch){
writeRedisLog('create_curl', $activity_id, $mobile, $user_id, '', 0, 'curl failed to initialize');
}
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
writeLog($activity_id, $mobile, $user_id.'_H');
$res = curl_exec($ch);
$return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error_no = curl_errno($ch);
$error_str = curl_error($ch);
curl_close($ch);
//if(!$res){
writeRedisLog('error_request', $activity_id, $mobile, $user_id, $res, $error_no, $error_str);
//}
//推送結(jié)果處理
$res = json_decode($res, true);
curl操作請求接口的日志:
_H===15515420703=2018-06-25 16:53:25=http://myhost.com/special/car... (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
在接口中打印的日志:
有遇到這種情況的嗎
總結(jié)
以上是生活随笔為你收集整理的php请求接口两次,php curl post请求执行一次curl_exce 请求的接口确执行两次的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql3错误_第3行MYSQL语法错
- 下一篇: 计算机怎么远程桌面,电脑远程桌面如何连接