大家好,我在curl请求中遇到了一个问题,我必须在其中发送很多信息或标头。我必须设置
用户代理
Sso令牌
订阅者ID
lbcookie
频道ID
Srno
唯一ID
Appkey
操作系统 版本
操作系统类型
设备类型
设备密钥
版本 代码
语言ID
用户组
主机
连接
接受 编码
我必须发送一个我发送的get请求,但是它失败并且返回无法处理该请求或无数据的空白页。
预先感谢您 PHP初学者
答案 0 :(得分:0)
将标题添加到$customHeaders
数组中,看看是否可行:
//The URL you're sending the request to.
$url = 'https://www.example.comp';
//Create a cURL handle.
$ch = curl_init($url);
//Create an array of custom headers.
$customHeaders = array(
'Accept-Encoding: gzip, deflate, br',
'Cookie: PHPSESSID=ciqas3vp82m514iubpr1b0md3o;',
'Referer: https://www.google.com/',
// add the headers you want to send as such
);
//Use the CURLOPT_HTTPHEADER option to use the custom headers.
curl_setopt($ch, CURLOPT_HTTPHEADER, $customHeaders);
//Execute the request
curl_exec($ch);
有关更多详细信息,请参见curl_setopt的文档