file_get_contents
请求具有POST数据和cookie集的URL。
$postdata = http_build_query(
array(
'search' => 'test',
'token' => '0'
)
);
// Create a stream
$opts = array(
'http'=> array(
'method'=>"POST",
'content' => $postdata,
'header' => "Content-Type: application/x-www-form-urlencoded\n"."Cookie: session_hash=123456789"
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file = file_get_contents('https://example.com', false, $context);
echo $file;
这是我看到的数据,但是
Cookie
在请求期间未发送。。。
我也尝试过使用相同的请求,但是对于CURL,我有同样的问题。
谢谢!