Using the fsockopen ()-function
| From: | Björne | Date: | Thu, 24 Jan 2002 22:09:08 +0000 |
| Subject: | Using the fsockopen ()-function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-81978@lists.php.net to get a copy of this message | ||
Hi! I'm having trouble with the fsockopen ()-funcion.
When I'm using the code below, the page that is returned is all white. What
to do? Am I doing anything wrong?
-----
$sp = fsockopen ( "www.php.net", 80, &$errno, &$errstr, 25 );
if ( !$sp ) {
die ( $errno . ": " . $errstr );
}
else {
fputs ( $sp, "POST /page.php HTTP/1.1\n" );
fputs ( $sp, "Host: www.php.net\n" );
fputs ( $sp, "Content-Type: application/x-www-form-urlencoded\n" );
fputs ( $sp, "Content-Length: " . strlen ( $mystr ) . "\n\n" );
fputs ( $sp, $mystr . "\n" );
while ( !feof ( $sp ) )
$str .= fgets ( $sp, 156 );
fclose ( $sp );
}
-----
PHP Regards,
Björn Wikström
bjorne@command.nu