PHP Curl implementation of HTTP and HTTPS request method, Phpcurlhttps request
This article describes the Php Curl implementation of HTTP and HTTPS request method, share to everyone for your reference. Specific as follows:
Generally speaking, PHP's Curl function group can help us to take the machine disguised as adult behavior to crawl the site, below to share two examples, one is to visit the HTTP Web page, a visit to HTTPS Web page, together to see.
Every time you use curl, you always have to look up a bunch of data.
Now will be used to save a few sentences, the province of every time to Google.
Regular Curl Requests:
Copy the Code code as follows: $url = ' http://www.bkjia.com ';
$curl = Curl_init ();
curl_setopt ($curl, Curlopt_url, $url);
curl_setopt ($curl, Curlopt_header, 1);
curl_setopt ($curl, Curlopt_returntransfer, 1);
$data = curl_exec ($curl);
Curl_close ($curl);
Var_dump ($data);
To request HTTPS using curl:
Copy the Code code as follows: $url = ' https://www.jb51.net ';
$curl = Curl_init ();
curl_setopt ($curl, Curlopt_url, $url);
curl_setopt ($curl, Curlopt_header, 1);
curl_setopt ($curl, Curlopt_returntransfer, 1);
curl_setopt ($curl, Curlopt_ssl_verifypeer, false);//This is the point.
$data = curl_exec ($curl);
Curl_close ($curl);
Var_dump ($data);
Attention
When requesting HTTPS data, a certificate is required, which, when combined with the following two parameters, avoids SSL certificate checking
Copy the Code code as follows: curl_setopt ($ch, Curlopt_ssl_verifypeer, FALSE); HTTPS request does not validate certificate and hosts
curl_setopt ($ch, Curlopt_ssl_verifyhost, FALSE);
I hope this article is helpful to everyone's PHP programming.
Problems with using curl to submit post data to HTTPS websites in PHP
The error message is a protocol that cannot support HTTPS.
Stackoverflow.com/...-https saved me, thank goodness.
said that there is more space in front of HTTPS
For the HTTPS protocol Web site, you can use the PHP curl to simulate get and post, you can get the return value?
OK.
Curlopt_protocols
The bit field of the curlproto_* refers to. If enabled, the bit-domain value qualifies libcurl for the protocols that are available for use during transmission. This will allow you to support a number of protocols when compiling libcurl, but the limit is just a subset of what is allowed in them. The default libcurl will use all of the protocols it supports. See Curlopt_redir_protocols.
The available protocol options are: Curlproto_http, Curlproto_https, Curlproto_ftp, Curlproto_ftps, CURLPROTO_SCP, Curlproto_sftp, CURLPROTO_ TELNET, Curlproto_ldap, Curlproto_ldaps, Curlproto_dict, Curlproto_file, Curlproto_tftp, Curlproto_all
By the right, the return value can be determined.
http://www.bkjia.com/PHPjc/897689.html www.bkjia.com true http://www.bkjia.com/PHPjc/897689.html techarticle PHP's Curl implementation of HTTP and HTTPS request method, Phpcurlhttps request The example of this article describes the Php Curl implementation of HTTP and HTTPS request method, share to everyone for your reference. Specific as follows: ...