PHP Curl Request for HTTPS encounter pit

Source: Internet
Author: User

PHP's certificate configuration for HTTPS is server-side-verified by default, and the HTTPS path cannot be requested if certificate validation is not configured on the server side. If you do not need to configure an HTTPS certificate for ease of use, configure curl with the following two keys set to False

curl_setopt ($ch, Curlopt_ssl_verifypeer, FALSE);
curl_setopt ($ch, Curlopt_ssl_verifyhost, FALSE);

Attach the complete function:
Private Function HttpGet ($url) {
$ch = Curl_init ();
Setting options, including URLs
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_ssl_verifypeer, FALSE);
curl_setopt ($ch, Curlopt_ssl_verifyhost, FALSE);
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_header, 0);
Execute and get HTML document content
$output = curl_exec ($ch);
Releasing the curl handle
Curl_close ($ch);
Print the obtained data
return $output;
}

PHP Curl Request for HTTPS encounter pit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.