PHP's cURL: How to connect over HTTPS?

前端 未结 5 1209
余生分开走
余生分开走 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 12:49

    This code can use to retrieve https requests

    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL,'https://serverurl.com/');
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    
    $data1 = curl_exec($ch);
    curl_close($ch);
    

提交回复
热议问题