使用 PHP 从 HTTP 帖子更改为 HTTPS 帖子
首先,作为一名网络开发人员,我完全是新手。我有一个 PHP 函数,可以处理 HTTP 的 post 请求,而且效果很好。我在网上读到一些地方说,要使相同的功能发布到 HTTPS,我所要做的就是将我所访问的端口从端口 80 更改为端口 443。因此,不要像这样:
$fp = fsockopen($host, 80, $errno, $errstr, 30);
它看起来像这样:
$fp = fsockopen($host, 443, $errno, $errstr, 30);
不幸的是,这个改变似乎不起作用。所以我的问题是:
我需要更改的只是端口号吗?
如果还有更多事情要做,那么我还需要做什么?
请尽量使用尽可能简单的术语,因为我是第一个承认我对此类内容非常陌生的人。
非常感谢大家。
First off, I'm a complete novice as a web developer. I have a PHP function that handles a post request for HTTP, and it works great. I read a few places online that all I have to do to make that same function post to HTTPS is change the port I'm hitting from port 80 to port 443. So instead of looking like this:
$fp = fsockopen($host, 80, $errno, $errstr, 30);
It would look like this:
$fp = fsockopen($host, 443, $errno, $errstr, 30);
Unfortunately, this change doesn't seem to be working. So my questions are these:
Is it true that all I have to change is the port number?
If there is more to do, than what is it I still need to do?
Please try to keep things in as simple terms as possible, since I am the first to admit I'm very new to this kind of stuff.
Thanks a ton everyone.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不
您必须协商 SSL 连接并通过它传输 HTTP 请求。
不要尝试使用套接字执行此操作。使用为其设计的库,例如 cURL。
No
You have to negotiate an SSL connection and tunnel the HTTP request through it.
Don't try to do this with sockets. Use a library designed for it, such as cURL.
来自 php.net:
尝试在您的 $host 前面添加 ssl:// (但也要保留端口 443;
From php.net:
Try prepending ssl:// to your $host (but also keeping port 443;