Reputation: 23
I need to change the headers that PHP sends when it requests a file using file_get_contents(). Is that possible or would I have to use CURL?
Upvotes: 0
Views: 259
Reputation: 3947
You can use file_get_contents() in conjunction with stream_context_create()
Exemple :
<?php
$context = stream_context_create(array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
)
));
$out = file_get_contents($filename, false, $context);
Upvotes: 5
Reputation: 1545
You will need to use CURL. It's also more reliable. See curl_setopt and CURLOPT_HTTPHEADER.
Upvotes: 0