You should be putting the post body in the 'content' field of the http context options, and no need to specify the content length.
$authContext = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => "Authorization: Basic ".base64_encode(($consumerKey).':'.($consumerSecret))."\r\n".
"Content-type: application/x-www-form-urlencoded;charset=UTF-8\r\n",
'content' => 'grant_type=client_credentials',
),
));
Do that same for the other http request you make.