file_get_contents() returns quot;failed to open streamquot; when hitting HTTPS(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.
这篇关于file_get_contents() 返回“未能打开流";访问 HTTPS 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:file_get_contents() 返回“未能打开流";访问 HTTPS 时
基础教程推荐
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- php中的foreach复选框POST 2021-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- php中的PDF导出 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
