警告:file_get_contents():代码为1的SSL操作失败。OpenSSL错误消息

时间:2018-07-29 09:45:07

标签: php

  

我已经检查了一些关于stackoverflow的解决方案,我看到了同样的问题   标题从这里开始,但是没有解决,这里也不是同样的问题。

我收到以下警告:

第一个警告

Warning: file_get_contents(): SSL operation failed with code 
1. OpenSSL Error messages: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1
alert protocol version in

第二警告

Warning: file_get_contents(): Failed to enable crypto in

第三警告

Warning: file_get_contents(https://www.abcdef.com/): failed to open stream:
operation failed in

显示以上所有警告的代码:

$contents = file_get_contents($url, $use_include_path, $context, $offset);

完整功能在这里:

function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
{
    // We DO force the tags to be terminated.
    $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
    // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
    $contents = file_get_contents($url, $use_include_path, $context, $offset);
    // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
    //$contents = retrieve_url_contents($url);
    if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
    {
        return false;
    }
    // The second parameter can force the selectors to all be lowercase.
    $dom->load($contents, $lowercase, $stripRN);
    return $dom;
}

所有警告均显示在localhost上,联机服务器不显示任何警告。

我的责任是:如何使它在没有警告的情况下工作?有人可以在这里帮助我吗?

完整代码为 HERE

0 个答案:

没有答案