duanpa5237 2018-03-26 19:30
浏览 102
已采纳

PHP从URL获取数据

I'm having problems with fetching data from URL. When I input URL in browser file normally gets downloaded to my computer, but when I try to access it in my code I get response FALSE, with no errors just bool(false) response. It's function for ICAL sync and 3 or 4 urls are fine but that one is just not getting data. Tried both with file_get_contents and with CURL. Here is CURL function:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    curl_close($ch);

Here are some info about server:

PHP Version = 5.6.10-pl0

allow_url_fopen = On

OpenSSL support = enabled

And yeah file is on HTTPS server if that's maybe an issue. Thank you guys in advance.

  • 写回答

1条回答 默认 最新

  • dongta5621 2018-03-26 19:42
    关注

    In this answer local refers to your server, remote to the other one (the one you are trying to access).

    From the error message:

    SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

    it looks like your client and the server implementation cannot agree on a common cipher suite to use. This usually means one implementation is a bit dated.

    There is no problem with the remote certificate. This would have yielded a different error message.

    Check the remote server

    You can use for example SSL Server Test to determine which Protocol versions and ciphers the remote server is using.

    Then you can select some of them for curl to use (Source for code):

    curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, 'ECDHE-RSA-AES128-GCM-SHA256,...');
    

    Check the local/your server

    You said you are using PHP 5.6.10. This is quite a bit out of date. (It was released on 11 Jun 2015). The current 5.6 version branch is at 5.6.34. If I was you I would consider an upgrade.

    From the SSL Server test: The remote server only accepts TLS1.2. So you should also consider upgrading your OpenSSL installation.

    Some more links for reference:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢