How to troubleshoot PHP Curl error

Source: Internet
Author: User
Tags ssl certificate

PHP Curl Common error: SSL error, BOOL (FALSE)

Symptom: Php Curl calls HTTPS error

Troubleshooting: Try using Curl on the command line.

Cause: The server's computer room cannot verify the SSL certificate.

Workaround: Skip the SSL certificate check.

curl_setopt ($ch, Curlopt_ssl_verifypeer, false);

Symptom: Php Curl call Curl_exec returns BOOL (false), command line curl is called normally.

How to Troubleshoot:

Var_dump (Curl_error ($ch));

Check initialization and execution of the return value of the Curl function. curl_error()and will curl_errno() return further information in the event of a failure:

try {$ch = Curl_init ();    if (FALSE = = = $ch) throw new Exception (' failed to initialize ');    curl_setopt ($ch, Curlopt_url, ' http://example.com/');    curl_setopt ($ch, Curlopt_returntransfer, 1);    curl_setopt (/* ... */);    $content = curl_exec ($ch);    if (FALSE = = = $content) throw new Exception (Curl_error ($ch), Curl_errno ($ch));        The. Process $content now} catch (Exception $e) {trigger_error (sprintf (' Curl failed with error #%d:%s '), $e->getcode (), $e->getmessage ()), e_user_error);} 
Related Article

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.