1. Curl requests the HTTPS protocol interface in Get mode
Note: The address here has a parameter, without parameters you handle it yourself oh get is simple
function Curl_get_https ($url){$curl = Curl_init ();//Start a Curl session curl_setopt ($curl, Curlopt_url,$url); curl_setopt ($curl, Curlopt_header, 0); curl_setopt ( $curl, Curlopt_returntransfer, 1 $curl, Curlopt_ssl_verifypeer, false); // Skip certificate check curl_setopt ($ Curl, Curlopt_ssl_verifyhost, true); //$ Tmpinfo = curl_exec ( $curl); // Returns the JSON object of the API//close URL request curl_close ( $curl return $tmpInfo; // return JSON object}
2. Curl requests the HTTPS protocol interface in post mode
/*PHP CURL HTTPS POST*/function Curl_post_https ($url,$data) {//Analog Commit data function$curl = Curl_init ();//Start a Curl session curl_setopt ($curl, Curlopt_url,$url);//The address to access curl_setopt ($curl, Curlopt_ssl_verifypeer, 0);//Inspection of the source of the certification certificate curl_setopt ($curl, Curlopt_ssl_verifyhost, 1);//Check that the SSL encryption algorithm exists from the certificate curl_setopt ($curl, Curlopt_useragent,$_server[' http_user_agent ');//Simulates the browser curl_setopt the user is using ($curl, curlopt_followlocation, 1);//Use Auto Jump curl_setopt ($curl, Curlopt_autoreferer, 1);//Set Referer curl_setopt automatically ($curl, Curlopt_post, 1);//Send a regular POST request curl_setopt ($curl, Curlopt_postfields,$DATA);//Post-Submitted packet curl_setopt ($curl, Curlopt_timeout, 30);//Set the timeout limit to prevent dead loops curl_setopt ($curl, Curlopt_header, 0);//Displays the contents of the header area returned curl_setopt ($curl, Curlopt_returntransfer, 1);// The information obtained is returned as a file stream $tmpInfo = curl_exec ($curl); // Perform action if (Curl_errno ($curl)) { echo ' errno '. Curl_error ($curl); Catch Exception } curl_close ($curl); // Turn off Curl session return $tmpInfo; // return data, JSON format}
Curl Requests the HTTPS protocol interface API separately in Get,post mode