$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);
//推送结果处理
$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
在接口中打印的日志:
有遇到这种情况的吗
1、php curl post请求接口,打印日志执行了一次curl_exce,但是请求的接口却重复执行两次.2、代码:$ch = curl_init();if(false === $ch){writeRedisLog('create_curl', $activity_id, $mobile, $user_id, '', 0, 'curl failed to initialize');}curl_s...