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);}