Socket w/SSL Issues
| From: | Steve Douville | Date: | Mon, 31 May 2004 13:14:55 +0000 |
| Subject: | Socket w/SSL Issues | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-187274@lists.php.net to get a copy of this message | ||
PHP is installed without openssl here at pair. I want to make a socket call
to port 443 on a server and I'm getting an error from fsocketopen() that no
ssl support is built in, of course. I thought that using "ssl://" might work
around this, but I guess not. Any ideas for me?
$host = "my.host.com";
$port = 443;
$path = "/my/app/path";
$request = urlencode('my xml request');
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, $timeout = 30);
if(!$fp){
//error tell us
echo "$errstr ($errno)\n";
}else{
//send the server request
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($request)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $request . "\r\n\r\n");
//loop through the response from the server
while(!feof($fp)) {
echo fgets($fp, 4096);
}
//close fp - we are done with it
fclose($fp);
}
Thanks in advance.
Steve