There is a response from the server contains a custom header "errcode":
Date: Wed, 24 Aug 2016 09:06:04 GMT
errcode: 1
Server: nginx/1.8.1
Connection: keep-alive
Transfer-Encoding: chunked
401 Unauthorized
How do I get by using PHP+CURL "errcode" value?
$ch = curl_init($url);
if ($ch) {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_HEADER, true); // we want headers
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$json = curl_exec( $ch );
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$transfer = curl_getinfo($ch);
curl_close($ch);
}
echo $httpcode; ?> //200,401 etc
<pre><?=print_r($transfer);?></pre> //array, no contains "errcode"