复制代码 代码如下:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); //url地址
curl_setopt($ch, CURLOPT_POST, true); //是否post请求
curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //post请求传递的数据
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);//设置header
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//返回获取的输出文本流
$response = curl_exec($ch); //获取返回的数据
curl_close($ch); //关闭