appid: wx4490e0448c6eb389
openid: o20udvzbUaMXxqfrRX6PIJ9X84WU
模板ID:iiqZPy_pUsHOgc_mbVRqU0Bl-HHsezeMrmhawR282u8
时间:2020-08-24 14:57:02
只请求了一次
PHP CURL代码:
public function http_request($url,$dataJson=NULL,$headers=NULL){
//$headers = array('Content-Type:application/json');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
if(!empty($dataJson)){
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataJson);
}
if(stripos ( $url, "https://" ) !== FALSE){
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, FALSE );
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5 );
if( !empty($headers)){
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$tmpInfo = curl_exec($ch);//echo $tmpInfo;
if (curl_errno($ch)) {
return curl_error($ch);
}
curl_close($ch);
return (array)json_decode($tmpInfo);
}
已解决,后面通过检查浏览器请求状态发现是浏览器发起了2次请求。