我正在尝试发送一个 http 请求,但我注意到当我尝试PHPSESSID
作为 COOKIE 发送时,我收到了警告:
file_get_contents(' http://mysite.localhost '):打开流失败:HTTP 请求失败
代码:
$options = array(
'http' => array(
'header' =>
"Content-type: application/x-www-form-urlencoded\r\n".
"Cookie: {$this->COOKIE}\r\n",
'method' => $this->method,
'content' => $this->POST,
),
);
$c = file_get_contents($this->uri, false, stream_context_create($options));
if(!$c)
throw new \Exception("Unable to fetch the request...");
echo $c;
编辑
的 var_dump 输出:
var_dump($this->COOKIE, $this->method, $this->POST);
是
string(53) "HI=COOKIE; L=S; PHPSESSID=o1eqt811isceh4f0nhfnnlnm70"
string(4) "POST"
string(6) "POST=VALUE"
我究竟做错了什么?