With PHP, is it possible to send HTTP headers with file_get_contents()
?
I know you can send the user agent from your php.ini
file. However, can you also send other information such as HTTP_ACCEPT
, HTTP_ACCEPT_LANGUAGE
, and HTTP_CONNECTION
with file_get_contents()
?
Or is there another function that will accomplish this?
Yes.
When calling file_get_contents on a url, one should use the stream_create_context function, which is fairly well documented on php.net
This is more or less exactly covered on the following page at php.net in the user comments section: http://php.net/manual/en/function.stream-context-create.php