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 时
基础教程推荐
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何替换eregi() 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
