hostname
If OpenSSL support is installed, you may prefix the
hostname
with eitherssl://
ortls://
to use an SSL or TLS client connection over TCP/IP to connect to the remote host.
The port would also need to change to 443
. So:
$header .= "Host: www.paypal.com\r\n"; ... $fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30); ... fputs ($fp, $header . $req);
https://
would not work because you’re opening a socket, which is a low-level transport. HTTP is an application level protocol on top of that, which the socket doesn’t know or care about. At the socket level it’s a TLS connection.
Also, is the fact my shop website is not HTTPS a problem, will this connection be refused?
What kind of connection a browser has to your server is irrelevant and nobody knows that. You’re opening a socket from a PHP program to Paypal, you may as well be doing that directly from the command line without any “HTTP” connection involved at all.