Unable to find the socket transport “https”

邮差的信 提交于 2019-12-01 15:35:09

also for ssl you need to prefix the host with ssl://

Sérgio

Uncomment the line: extension=php_openssl.dll in php.ini

You should be using just the hostname, not the URL in the fsockopen call. You'll need to provide the uri, minus the host/port in the actual HTTP headers. As @Martijin noted, and as listed in the manual page, you'll need to preface your host name with ssl:// for SSL or tls:// if using transport layer security.

Manual page for fsockopen. Look at Example #1.

Let's say you wanted to grab NY Times, which enforces HTTPS:

Incorrect:

$client = stream_socket_client('https://www.nytimes.com', $errno, $errstr, 30);

Correct:

$client = stream_socket_client('tcp://www.nytimes.com:443', $errno, $errstr, 30);

Note I've replaced https:// with tcp:// and appended the 443 port to the hostname.

I guess we can say that stream_socket_client() does not speak URLs.

Tony Schmidt

Switching to ssl:// worked for me but I kept getting a BAD REQUEST response. I found that I needed to add one more line to declare explicitly my Host Header as described here and ensure that I've updated my HTTP from HTTP/1.0 to HTTP/1.1:

$header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host: www.sandbox.paypal.com\r\n";

Check curl installed or not for php. if it is not installed install the curl. for windows Uncomment the line: extension=php_openssl.dll in php.ini, for ubuntu sudo apt-get install php-curl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!