PHP's cURL: How to connect over HTTPS?

前端 未结 5 1194
余生分开走
余生分开走 2021-02-15 12:23

I need to do a simple GET request to EC2 Query API with regular URL encoded query string. The protocol is HTTPS. How would I send the request with the help of PHP\'s cURL.

5条回答
  •  执笔经年
    2021-02-15 13:12

    If you want to configure CURL to blindly accept the certificate you can set the CURLOPT_SSL_VERIFYPEER option to false.

    $url = 'https://www.example.com/abc';
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    // Blindly accept the certificate
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
    $response = curl_exec($ch);
    curl_close($ch);
    
    var_dump($response);
    

提交回复
热议问题