file_get_contents() 返回“未能打开流";访问 HTTPS 时
当我在 HTTPS URL 上调用 file_get_contents() 时,它返回无法打开流".
file_get_contents() is returning "failed to open stream" when I call it on an HTTPS URL.
Warning: file_get_contents(https://google.com) [function.file-get-contents]: failed to open stream: No error in E:\htdocscallback3.php on line 5
相同的调用将使用非 SSL URL.
Same call will work with a non-SSL URL.
起初,我认为这是我的虚拟主机的安全问题,但我已经用 phpinfo() 验证了 allow url open 确实是允许的.我也试过这段代码并验证它有效:
At first, I thought it was a security issue with my webhoster, but I have verified with phpinfo() that allow url open is indeed allowed. I have also tried this code and verified it works:
有人知道为什么 file_get_contents() 使用 HTTPS URL 失败了吗?
Anyone have any ideas why file_get_contents() is failing with an HTTPS URL?
更新: 人们正确地指出这是一个 HTTPS 问题.我的虚拟主机声称这应该可以工作,但不知道如何解决这个问题.任何人都可以为他们的 IIS7 设置提供具体的指导吗?
update: People correctly pointed out this was an HTTPS issue. My webhoster claims this should work, and has no idea how to resolve this. Anyone have specific directions I can give them for their IIS7 setup?
推荐答案
那可能是因为他们使用的是安全协议https
.这很奇怪,在他们的例子中,facebook 给出了类似的例子.
That is probably because they are using the secure protocol https
. This is strange though, in their examples, facebook is giving the similar example.
相关文章