php,sockets-help!
| From: | Sandeep Murphy | Date: | Wed, 09 Jan 2002 16:23:09 +0000 |
| Subject: | php,sockets-help! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-79925@lists.php.net to get a copy of this message | ||
Hi,
I am opening a socket on a remote server(weblogic) and sending my username
and psswd to authentify them...
I figure my php is opening the socket as no errors r being trapped.. However
the response is a blank page instead of an xml formatted response...why???
how can i rectify this??
Please helpp!!!
TIA,
sands
my code is as below:
<?php
$uname = "username";
$password = "password";
?>
<?php
$Destination = "http://srv157:7001/communicatorServlet";
$Request = "username=$uname&password=$password";
$cfgTimeOut = 20;
$theURL = parse_url($Destination);
$host = $theURL["host"];
$path = $theURL["path"];
$port = $theURL["port"]; if ($port=="") $port=80;
$header = "GET ".$path." HTTP/1.0\r\n";
$header .= "Host: ".$host."\r\n";
$header .= "Accept: */*\r\n";
$header .= "Accept-Language: en\r\n";
$header .= "User-Agent: PHP/4.0.6 (Apache/1.3.20)\r\n\r\n";
$header .= "Content-Type: text/xml\r\n";
$header .= "Content-Length: ".strlen($Request)."\r\n";
$header .= "Content: \r\n\r\n";
$msg = $header . $Request;
$Response = "";
// open a socket
if(!$cfgTimeOut)
// without timeout
$fp = fsockopen($host,$port);
else
// with timeout
$fp = fsockopen($host,$port, &$errno, &$errstr, $cfgTimeOut);
if ($fp) {
if (!fputs($fp,$msg,strlen($msg))) { return false; } // S
E N D
while (!feof($fp)) {$Response .= fgets($fp,32768);}
fclose($fp); // R E C E I V E
} else
{
echo "Unable to access servlet (".$Destination.").<br>";
echo "<a
href=\"javascript:history.go(-1)\">Try another</a>";}
print "$response\n";
print "hello";
?>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
For additional commands, e-mail: php-windows-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net