Phpcurl implements http and https request instances. Phpcurl implements http and https request instances. each time you use curl, you always need to check a bunch of data. Now we can save a few frequently used sentences, saving every time we go to Google. Conventional curl requests: php curl implements http and https request instances
Each time you use curl, you always need to check a bunch of data.
Now we can save a few frequently used sentences, saving every time we go to Google.
Common curl requests:
| The code is as follows: |
|
$ Url = 'http: // www.111cn.net ';
$ 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 ); |
Use curl to request HTTPS:
| The code is as follows: |
|
$ Url = 'https: // www.111cn.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 focus.
$ Data = curl_exec ($ curl );
Curl_close ($ curl );
Var_dump ($ data ); |
Note:
When requesting https data, the certificate is required. at this time, the following two parameters are added to avoid ssl certificate check.
| The code is as follows: |
|
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https requests do not verify the certificate and hosts
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, FALSE ); |
Http://www.bkjia.com/PHPjc/895094.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/895094.htmlTechArticlephp curl implements http and https request instance each time you want to use curl, always need to check a bunch of information. Now we can save a few frequently used sentences, saving every time we go to Google. Regular curl request :...