blakefan
V2EX  ›  PHP

file_get_contents 以及 curl 返回 false 怎么解决?

  •  
  •   blakefan · Aug 6, 2015 · 6023 views
    This topic created in 4118 days ago, the information mentioned may be changed or developed.
    我请求的微信公众平台去 获取access_token 在本地试都是好的,到了服务器上 file_get_contents 以及curl返回都是false 获取不到 返回数据 检测过file_get_contents 已经开启 方法存在。如果开启curl也可以获取到资源 但是请求url返回的值一直是false
    6 replies  •  2015-08-08 17:54:43 +08:00
    realpg
    realpg
    Aug 6, 2015
    1
    我猜你的PHP是5.6,而且访问的URL是https

    如果我猜对了,请看
    http://php.net/manual/zh/migration56.openssl.php
    如果我没猜对,请继续……
    imn1
    imn1
    Aug 6, 2015
    2
    服务器上php对外请求的的安全选项没有开启
    blakefan
    blakefan
    OP
    Aug 6, 2015
    3
    @imn1 你说的应该是php.ini 里面的 extension=openssl.dll这个扩展。但是我这边已经开启了
    vibbow
    vibbow
    Aug 6, 2015
    4
    cURL把调试信息打开

    $verbose = fopen('php://temp', 'rw+');

    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_STDERR, $verbose);

    rewind($verbose);
    $verboseLog = stream_get_contents($verbose);
    echo $verboseLog;
    zencoding
    zencoding
    Aug 8, 2015
    5
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    blakefan
    blakefan
    OP
    Aug 8, 2015
    6
    @zencoding 已解决 谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1981 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 10:14 · PVG 18:14 · LAX 02:14 · JFK 05:14
    ♥ Do have faith in what you're doing.