note 41532 modified in function.fopen by tomsommer

From: Date: Fri, 07 May 2004 20:19:25 +0000
Subject: note 41532 modified in function.fopen by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-69328@lists.php.net to get a copy of this message
If you're using fopen to open a URL that requires authorization, you might need to force a HTTP/1.0 request for it since fopen won't support HTTP/1.1 requests. You can do that by setting your user_agent to one that is known only to support HTTP/1.0 (most webservers will be configured to force HTTP/1.0 for some browsers). Here's what worked for me: <?php $returned=URLopen("http://$username:$password@example.com"); function URLopen($url) { // Fake the browser type ini_set('user_agent','MSIE 4\.0b2;'); $dh = fopen("$url",'r'); $result = fread($dh,8192); return $result; } ?> --was-- If you're using fopen to open a URL that requires authorization, you might need to force a HTTP/1.0 request for it since fopen won't support HTTP/1.1 requests. You can do that by setting your user_agent to one that is known only to support HTTP/1.0 (most webservers will be configured to force HTTP/1.0 for some browsers). Here's what worked for me: $returned=URLopen("http://$username:$password@example.com"); function URLopen($url) { // Fake the browser type ini_set('user_agent','MSIE 4\.0b2;'); $dh = fopen("$url",'r'); $result = fread($dh,8192); return $result; } http://www.php.net/manual/en/function.fopen.php

« previous php.notes (#69328) next »