【发布时间】:2017-03-02 08:59:32
【问题描述】:
当我使用带有 url(http://google.com 或其他)的 file_get_contents 或 curl_exec 时,在不同的上下文、user_agent 等下返回 false...没有错误没有警告
使用本地文件,例如:file_get_contents("a.txt");
配置:
Php.ini 是对的:allow_url_fopen = On
没有防火墙:sudo ufw 状态:非活动
Phpinfo():
协议:dict、file、ftp、ftps、gopher、http、https、imap、imaps、ldap、ldaps、pop3、pop3s、rtmp、rtsp、smtp、smtps、telnet、tftp
主机:x86_64-pc-linux-gnu
SSL:版本 OpenSSL/1.0.1e
OpenSSL:支持启用
OpenSSL:库版本 OpenSSL 1.0.1e 2013 年 2 月 11 日
OpenSSL:标头版本 OpenSSL 1.0.1e 2013 年 2 月 11 日
它是一个专用服务器,也许有物理防火墙?还是我无法控制的东西?
非常感谢
【问题讨论】:
-
尝试将
context参数添加到包含file_get_contents的useragent- 与您的 curl 请求类似 -
告诉我们错误是什么?
-
是的,我试过了。 user_agent 不同的上下文。 curl_exec 也不起作用
-
没有错误,没有警告,正如我所说的,它适用于本地文件
-
您提到了 google,但这是您尝试的实际网址,还是您的呼叫失败的特定网址?