How to catch cURL errors in PHP?
"You can use the curl_error() function".
How to check cURL response in PHP?
Response Headers in cURL
By setting the CURLOPT_HEADER and CURLOPT_NOBODY options to true, the result of curl_exec() will only contain the headers. This is useful when you only need the headers, but most of the time, we need the content of the request too. The solution to this lies in the CURLOPT_HEADER option as well.