physaux Posted November 4, 2009 Share Posted November 4, 2009 Hey guys, I was wondering if someone could point me somewhere on how I could modify php's "header information" or something like that, so that when I read another page with fopen($url, "r"), I don't want it to know that php is accessing it. Some sites block php's header, so I would like to change it to look like firefox's or something. Any clues? Quote Link to comment https://forums.phpfreaks.com/topic/180342-solved-how-to-modify-phps-header-when-opening-a-url-with-fwrite-r/ Share on other sites More sharing options...
.josh Posted November 4, 2009 Share Posted November 4, 2009 curl Quote Link to comment https://forums.phpfreaks.com/topic/180342-solved-how-to-modify-phps-header-when-opening-a-url-with-fwrite-r/#findComment-951344 Share on other sites More sharing options...
salathe Posted November 4, 2009 Share Posted November 4, 2009 There are no special "PHP headers" sent (unless you define them yourself, not by default) informing remote sites that it is PHP grabbing the file rather than a normal person via a browser. However (again by default) PHP will not send the same headers that a browser might. The most usual difference is that no User-Agent header is sent from PHP scripts. You can send one using, as Crayon Violent so succinctly pointed out, cURL, or you can continue using fopen and provide a stream context specifying the user agent header to send. Useful links for the latter include: http://php.net/fopen (see 4th parameter) http://php.net/stream_context_create (to create a stream context) http://php.net/context.http (options for a HTTP stream context) http://php.net/filesystem.configuration#ini.user-agent (ini setting for the default UA to send from fopen, file_get_contents, etc.) Quote Link to comment https://forums.phpfreaks.com/topic/180342-solved-how-to-modify-phps-header-when-opening-a-url-with-fwrite-r/#findComment-951363 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.