note 53497 deleted from function.fopen by wez

From: Date: Tue, 09 Aug 2005 20:42:03 +0000
Subject: note 53497 deleted from function.fopen by wez
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-93338@lists.php.net to get a copy of this message
Note Submitter: Danniel@t h e - police (d'0't) com ---- When used with URL address, I've seen some scripts that use fsockopen() instead of fopen() becouse you have more power (control) over the headers you are sending. This control passes you the job of interpreting the headers sent to you (e.g. Location, Redirect, must be interpreted by you to actually receive the page you are redirected to). I believe fopen() works faster and interprets the headers received. If you are trying to send/change header User-Agent in an request you can use ini_set() : ini_set("user_agent","Opera/8.0 (compatible; MSIE 6.0; Windows NT 5.0)\r\n"); $wp=fopen("http://www.yourURLaddress.com/","r"); // ... fclose($wp); "user_agent" is a php variable sent by PHP when a fopen with URL is made. My idea is that some of the headers (not only User-Agent) can be sent to server by appending the headers you need to send to the user_agent variable. To send User-Agent and Language use: <?php $header = "Opera/8.0 (compatible; MSIE 6.0; Windows NT 5.0)\r\n"; $header .= "Accept-Language: ro-en\r\n"; $content = ''; ini_set("user_agent",$header); $wp=fopen("http://www.yourURLaddress.com/","r"); // here you receive content of page while(!feof($wp)) { $content .= fread($wp,4096); } fclose($wp); ?> You can try with diferent headers to see if it works, I only needed the Language to be sent and it saved me some time.

« previous php.notes (#93338) next »