PHP Curl Usage

Source: Internet
Author: User
Tags ssl certificate

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.

    1. 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.
    2. Some option notes for curl_setopt:
    3. CURLOPT_RETURNTRANSFER默认是false。当设置为true时,请求后的内容就不会直接输出,而是通过curl_exec()返回。很有用。
    4. CURLOPT_HEADER默认是false。当设置为true时,请求头部会输出。当cookie字段在头部返回时,就有必要将CURLOPT_HEADER设置为true了。
    5. CURLOPT_SSL_VERIFYPEER默认是true,当访问https站点时,即会验证证书。在windows系统下curl一个https站点时,会提示SSL certificate problem: unable to get local issuer certificate,就有必要将CURLOPT_SSL_VERIFYPEER设置为false来方便调试了。
    6. CURLOPT_SSL_VERIFYHOST默认为2,验证host名称。可设置为false,不验证。
    7. 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

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.