I'm getting 400 response code for an HTTP request. I want to read the response message in PHP. I'm reading response code like this:
$options = array(
'http' => array(
'header' => "Content-type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($data)
),
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if(strrpos($http_response_header[0], '200')){
echo '200'."<br/>";
return $result;
}
elseif(strrpos($http_response_header[0], '400')){
echo '400'."<br/>";
return $result;
}
I'm getting result = bool(false) in the case of response code 400.