I am new to PHP. I am trying to make a HTTPS POST request from PHP to an external server. Based on the posts on the Internet I have the following code:
// Create POST data.
$post_data = array(
    'roomId' => $space_token,
    'text' => $message
);
$output .= json_encode($post_data);
// Creating context
$context = stream_context_create(array(
    'http' => array(
        'method' => 'POST',
        'header' => "Authorization: Bearer {$api_access_token}\r\n".
              "Content-Type: application/json\r\n",
        'content' => json_encode($post_data)
    )
));
$response = fopen($api_url, 'r', false, $context);
However, the request is made with HTTP/1.0 instead of HTTP/1.1, and the server that i am trying to reach returns 502 Bad Gateway response when it receives HTTP/1.0 requests.
PHP Version: 5.4.16
HTTPD Version: Apache/2.4.6 (CentOS)
Not sure what I am doing wrong.
 
    