【问题标题】:cURL error 35 SSL Connect Error on hostgator live servercURL 错误 35 在 hostgator 实时服务器上发生 SSL 连接错误
【发布时间】:2015-03-15 15:39:45
【问题描述】:

即使在 stackoverflow 上,我也在互联网上搜索了很多有关此问题的内容,但无法找到某些解决方案。我正在使用以下代码向 https 网站之一发出 curl 请求。

<?php 

/**
 * Get a web file (HTML, XHTML, XML, image, etc.) from a URL.  Return an
 * array containing the HTTP server response header fields and content.
 */
function get_web_page( $url )
{
    $options = array(
            CURLOPT_RETURNTRANSFER => true,     // return web page
            CURLOPT_HEADER         => false,    // don't return headers
            CURLOPT_FOLLOWLOCATION => true,     // follow redirects
            CURLOPT_ENCODING       => "",       // handle all encodings
            CURLOPT_USERAGENT      => "spider", // who am i
            CURLOPT_AUTOREFERER    => true,     // set referer on redirect
            CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
            CURLOPT_TIMEOUT        => 120,      // timeout on response
            CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
            CURLOPT_SSL_VERIFYPEER => false,     // Disabled SSL Cert checks
            CURLOPT_SSL_VERIFYHOST => false
    );

    $ch      = curl_init( $url );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;
    $header['content'] = $content;
    return $header;
}
echo '<pre>';
print_r(get_web_page('https://savedeo.com/download?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DbVl3om0-GFE'));die;

?>

此代码在我的 localhost xampp 上运行良好,但在 hostgator 共享主机上运行不正常。谁能告诉我确切的问题或我在这里做错了什么。

【问题讨论】:

  • echo phpinfo(); 并确保 curl 已安装并在共享主机上运行
  • 是的,它为 http 网站启用并正常工作
  • 请发布您的curl error

标签: php curl https


【解决方案1】:

将 'CURLOPT_VERBOSE => true' 添加到您的选项数组以提供更详细的输出,这应该可以为您提供原因。

如果您有权访问防火墙设置,请确保连接的端口实际上是打开的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-15
    • 2019-02-13
    • 2018-06-16
    • 2014-03-20
    • 1970-01-01
    • 1970-01-01
    • 2016-09-16
    • 2016-05-07
    相关资源
    最近更新 更多