我正在尝试通过PHP cURL登录网站,我只收到"错误请求"响应.
我玩了hosts文件并将其设置到我的服务器,以检查我的浏览器发送的请求标头,并将其与cURL发送的请求标头进行比较.
一切都是平等的,除了:
浏览器:
Content-Type: application/x-www-form-urlencoded
Content-Length: 51
Run Code Online (Sandbox Code Playgroud)
PHP cURL:
Content-Length: 51, 359
Content-Type: application/x-www-form-urlencoded; boundary=----------------------------5a377b7e6ba7
Run Code Online (Sandbox Code Playgroud)
我已经使用此命令设置了这些值,但它仍然发送错误的标头:
curl_setopt($this->hCurl, CURLOPT_HTTPHEADER, array(
'Expect:',
'Content-Type: application/x-www-form-urlencoded',
'Content-Length: 51'
));
Run Code Online (Sandbox Code Playgroud)