php http 请求数据
程序员文章站
2022-04-09 12:53:36
...
$url = 'https://......'; //请求地址
$ref_url = ''//来源页面
$data = array( //提交的数据
"param" => "",
"param" => ""
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_REFERER, $ref_url);
curl_setopt($ch, CURLOPT_POST, TRUE); //以POST方式提交
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //超时时间
$contents = curl_exec($ch); //执行并获取返回数据
curl_close($ch);
var_dump($contents);
上一篇: PHP实现微信发红包程序,php实现红包