Php-curl is an extension of the browser request using PHP impersonation. I only used a very simple part, some of the things to be aware of, make a record.
- It is recommended to run under the CLI, including debugging. Running in a browser may be affected by browser cookies, such as when you have already logged in to simulate the requested site.
- Some option notes for curl_setopt:
CURLOPT_RETURNTRANSFER默认是false。当设置为true时,请求后的内容就不会直接输出,而是通过curl_exec()返回。很有用。
CURLOPT_HEADER默认是false。当设置为true时,请求头部会输出。当cookie字段在头部返回时,就有必要将CURLOPT_HEADER设置为true了。
CURLOPT_SSL_VERIFYPEER默认是true,当访问https站点时,即会验证证书。在windows系统下curl一个https站点时,会提示
SSL certificate problem: unable to get local issuer certificate,就有必要将CURLOPT_SSL_VERIFYPEER设置为false来方便调试了。
CURLOPT_SSL_VERIFYHOST默认为2,验证host名称。可设置为false,不验证。
CURLOPT_VERBOSE默认为false。设置为true,会打印出请求时的详细信息,当curl_exec()返回false时,将此选项开启,看详细信息,会很有用处。
For the time being used so much, 5, 7 is more useful.
Again find useful places to add, attach an example: Https://coding.net/u/imzhi/p/iMabi/git
PHP Curl Usage