Tenho esse cURL que me traz um array como resposta, preciso saber qual o status code http dessa requisição:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $merchantApiHost.'/authentication/v1.0/oauth/token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'grantType=client_credentials&clientId='.$clientId.'&clientSecret='.$clientSecret,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$response = curl_exec($curl);
curl_close($curl);
$retorno = json_decode($response, true);
$accessToken = $retorno['accessToken'];
curl_getinfo
, com segundo parâmetroCURLINFO_RESPONSE_CODE
.$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE)
que me traz o code, agora consigo trabalhar com if: de acordo com o $httpcode