file_get_contents(): SSL operation failed with code 1, Failed to enable crypto

前端 未结 16 2007
情歌与酒
情歌与酒 2020-11-22 04:31

I’ve been trying to access this particular REST service from a PHP page I’ve created on our server. I narrowed the problem down to these two lines. So my PHP page looks li

16条回答
  •  感动是毒
    2020-11-22 04:54

    Working for me, I am using PHP 5.6. openssl extension should be enabled and while calling google map api verify_peer make false Below code is working for me.

    array(
             "verify_peer"=>false,
             "verify_peer_name"=>false,
        ),
    );  
    $url = "https://maps.googleapis.com/maps/api/geocode/json?latlng="
          . $latitude
          . ","
          . $longitude
          . "&sensor=false&key="
          . Yii::$app->params['GOOGLE_API_KEY'];
    
    $data = file_get_contents($url, false, stream_context_create($arrContextOptions));
    
    echo $data;
    ?>
    

提交回复
热议问题