Update
Please refer to the latest article "using PHP curl to access HTTPS"
Bytes --------------------------------------------------------------------------------------------------------------------
The title is a bit long. It is actually used to post data to the https server.
Function curlpost ($ URL, $ data, $ timeout = 30) <br/>{< br/> $ SSL = substr ($ URL, 0, 8) = "https: //"? True: false; <br/> $ CH = curl_init (); <br/> $ opt = array (<br/> curlopt_url => $ URL, <br/> curlopt_post => 1, <br/> curlopt_header => 0, <br/> curlopt_postfields => (array) $ data, <br/> curlopt_returntransfer => 1, <br/> curlopt_timeout => $ timeout, <br/>); <br/> if ($ SSL) <br/>{< br/> $ OPT [curlopt_ssl_verifyhost] = 1; <br/> $ OPT [curlopt_ssl_verifypeer] = false; <br/>}< br/> curl_setopt_array ($ ch, $ OPT); <br/> $ DATA = curl_exec ($ ch ); <br/> curl_close ($ ch); <br/> return $ data; <br/>}< br/> $ DATA = curlpost ('https: // ssl.test.com ', array ('p' => 'hello'); <br/> echo ($ data );
----------------------------- I am a split line --------------------------------
In fact, this tells the server not to perform SSL authentication and does not actually Use https.
To Use https, you must provide a CA certificate.
The preceding settings for SSL are as follows:
Set curlopt_ssl_verifypeer to true. This indicates that SSL certificate authentication is performed. Set curlopt_ssl_verifyhost to 2. Set curlopt_cainfo to the certificate path.