Curl HTTP Code 0

Source: Internet
Author: User

After a POST request with curl, the status code is received, and the result is 0, but the data returned by the request is normal.

After the check, it is the execution order problem:

        $response = [            ' statusCode ' =    curl_getinfo ($curl, Curlinfo_http_code),            ' body ' =          curl_exec   ($curl),            ' curlerrorcode ' = Curl_errno  ($curl),        ];

Because later change the structure, so did not care about the position of the curl_exec, the direct adjustment is used, so in the output, the value has been 0

After the adjustment is good, that is, should execute the $CURL request, and then to obtain the requested status code and other related parameters (no problem), because it was placed outside the array received, so there is no problem

        $response = [            ' body ' = =          curl_exec   ($curl),            ' curlerrorcode ' = ' Curl_errno  ($curl),            ' StatusCode '    = Curl_getinfo ($curl, Curlinfo_http_code),        ];

So we need to pay attention to the details and understand the principle of the problem.

Curl HTTP Code 0

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.