关于php curl请求,自动生成的:
------------------------------76e7fd6813a5 Content-Disposition: form-data, name
需设置http_build_query()即可:curl_setopt ( $curl, CURLOPT_POSTFIELDS,http_build_query($data))
<?php
public function cur_post($url,$data){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);// https请求 不验证证书和hosts
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10000);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type:application/x-www-form-urlencoded'));
curl_setopt ( $curl, CURLOPT_POSTFIELDS,http_build_query($data));//数据过滤,去掉curl自动生成的参数:------------------------------76e7fd6813a5\r\nContent-Disposition: form-data
//curl_setopt($curl, CURLOPT_POSTFIELDS, $data);//设置post数据
$res = curl_exec($curl);//执行命令
curl_close($curl);
return $res;
}
摘自:https://blog.csdn.net/veloi/article/details/80146660
网友评论