title: PHP HTTP/1.0 400 Bad Request from API Request with authorization headers
body: <p>I am trying to retrieve some data from an API that requires authentication via HTTPS. I have the correct authentication, however when using 'file_get_contents' to get the data I am getting the error:</p>
  
  <blockquote>
    <p>failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request   </p>
  </blockquote>
  
  <pre><code>$api_url = 'https://api...';
  
  $client_id = 'user';
  $client_secret = 'pass';
  
  $context = stream_context_create(array(
      'http' =&gt; array(
          'header' =&gt; "Authorization: Basic " . base64_encode("$client_id:$client_secret"),
      ),
  ));
  
  $result = file_get_contents($api_url, false, $context);
  </code></pre>
  
  <p>Would there be any particular reason why I am unable to get the data from the authenticated server?</p>