Actually, upon further reading on the file_get_contents()
function:
// Create a stream
$opts = [
"http" => [
"method" => "GET",
"header" => "Accept-language: en
" .
"Cookie: foo=bar
"
]
];
// DOCS: https://www.php.net/manual/en/function.stream-context-create.php
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
// DOCS: https://www.php.net/manual/en/function.file-get-contents.php
$file = file_get_contents('http://www.example.com/', false, $context);
You may be able to follow this pattern to achieve what you are seeking to, I haven't personally tested this though. (and if it doesn't work, feel free to check out my other answer)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…