Curl error troubleshooting
Php curl Common Errors: SSL errors, bool (false)
Symptom: An error occurred while calling https in php curl.
Troubleshooting method: Use curl in the command line to call it.
Cause: the SSL certificate cannot be verified in the server room.
Solution: Skip the SSL certificate check.
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, false );
Symptom: php curl calls curl_exec and returns bool (false). The command line curl call is normal.
Troubleshooting:
Var_dump (curl_error ($ ch ));
Check the returned values of the initialization and execution of the cURL function.curl_error()
And setcurl_errno()
In the event of a fault, further information is returned:
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)); // ...process $content now} catch(Exception $e) { trigger_error(sprintf( 'Curl failed with error #%d: %s', $e->getCode(), $e->getMessage()), E_USER_ERROR);}