PHP get_contents()错误

时间:2016-05-07 03:43:36

标签: php

使用PHP get_contents()时出现以下错误:

我在这里缺少什么?它在使用XAMPP的本地服务器中完美运行。

PHP Version 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警报握手失败第21行/home/XXXXXX/public_html/test.php

     

警告: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);

2 个答案:

答案 0 :(得分:0)

检查你的php.ini文件,取消注释 ;延长= php_openssl.dll 至 延长= php_openssl.dll 如果已经完成,请检查防火墙是否允许连接。 简单的方法是使用telnet。

答案 1 :(得分:-1)

我不认为问题出在您的代码中。我在我的Laravel流浪盒上进行了测试,效果很好。我认为问题出在你的$ url_api变量的数据中。