Re: fsockopen + fputs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



debussy007 wrote:
Hello,

I use fsockopen and fputs to call a distant URL, but I have the following
error : The requested URL /registration/test was not found on this server.

This is my code:

$req = 'username=' . $usr . '&password=' . $pass . '&date_of_birth=' . $year . "-" . $month . "-" . $day . '&email=' . $email . '&country=' . $country;

$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br>\n";
} else {
	$header = "POST /registration/test HTTP/1.0\r\n";
	$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
	$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
	fputs ($fp, $header . $req);
	
    while (!feof($fp)) {
		echo fgets($fp, 1024);
    }
    fclose($fp);
}

However the path www.example.com/registration/test exists
so why does it says it cannot find the requested url ?

Any idea ? Thank you for any help !!

try changing to
POST /registration/test/ HTTP/1.0\r\n

note the trailing slash on test
also if that fails try http/1.1

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux