用postman工具请求,就是没有问题,自己写的就是不好使,
这给我急眼的哦~
http_build_query 处理一下数组数据就可以了呢;
贴代码
public function curl_post($url,array $post =NULL)
{
$ch =curl_init();
curl_setopt( $ch,CURLOPT_CONNECTTIMEOUT ,120 );
curl_setopt( $ch,CURLOPT_TIMEOUT ,120);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);// https请求 不验证证书和hosts
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);//检查证书中是否设置域名,0不验证
// 执行HTTP请求
curl_setopt($ch ,CURLOPT_URL , $url);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($post));
$res =curl_exec($ch);
return $res;
}