沃梦达 / 编程问答 / php问题 / 正文

file_get_contents() 返回“未能打开流";访问 HTTPS 时

file_get_contents() returns quot;failed to open streamquot; when hitting HTTPS(file_get_contents() 返回“未能打开流;访问 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 时

基础教程推荐