【发布时间】:2016-09-02 05:29:24
【问题描述】:
使用 PHP get_contents() 时出现以下错误:
我在这里缺少什么?它在带有 XAMPP 的本地服务器中完美运行。
PHP 版本 5.3.29
SSL 版本 OpenSSL/0.9.8b
警告:file_get_contents() [function.file-get-contents]: SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:14077410:SSL 例程:SSL23_GET_SERVER_HELLO:sslv3 警报握手失败/home/XXXXXX/public_html/test.php 在第 21 行
警告:file_get_contents() [function.file-get-contents]:无法在第 21 行的 /home/xxxxx/public_html/test.php 中启用加密
警告:file_get_contents(https://.....XXXXXX) [function.file-get-contents]:无法打开流:操作失败
$url_api = "XXXXXXXXXXXXXX";
$getResult = array(
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
),
'http'=>array(
'method'=>"GET",
'header'=>"XXXXXX: xxxxxxxxxx\r\n"
));
$getContext = stream_context_create($getResult);
$getResponse = file_get_contents($url_api, false, $getContext);
【问题讨论】:
-
你是否为你的 php 安装了 openssl 扩展?
-
是的!启用 OpenSSL 支持我在 phpinfo() 中找到了它。我在上面添加了PHP版本...是因为较低的php版本吗?我用 CURL 测试过,它从来没有返回任何信息。 :)
-
allow_url_fopen开启? -
是的,本地值和主值都打开。
-
不太确定,但here 是类似的错误
标签: php