CURL of PHP functions: Summary of Common Problems

Source: Internet
Author: User
I. badrequest error returned for the request. Possible causes: 1. the url address is incorrect. manually enter a url in the address bar to check whether the request is normal. note: If the url contains a line break, the system may return a. 2.https request. You need to set the corresponding parameter # BelowtwooptionwillenabletheHTTPSoption. curl_setopt ($ c

I. 400 bad request error returned for the request. Possible causes: 1. the url address is incorrect. manually enter a url in the address bar to check whether the request is normal. note: If the url contains a line break, 400 may be returned. 2. for https requests, you must set the corresponding parameter # Below two option will enable the HTTPS option. curl_setopt ($ c

1. The error "400 bad request" is returned for the request. Possible causes:

1. the url address is incorrect.

Manually enter a url in the address bar to check whether the request is normal.

Note: If the url contains a line break, 400 may be returned.

2. parameters need to be set for https requests

# Below two option will enable the HTTPS option.
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, FALSE );
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, FALSE );

3. url_encode transcoding is required for the string passed in the url.

2. url redirection settings:

Curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects

Iii. submit data through POST

Curl_setopt ($ curl, CURLOPT_POST, 1); // send a regular Post request
Curl_setopt ($ curl, CURLOPT_POSTFIELDS, $ data); // data packet submitted by Post
Curl_setopt ($ curl, CURLOPT_TIMEOUT, 30); // sets the timeout limit to prevent endless loops.

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.