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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器