title: Why do I get a PHP error 406 when trying to use file_get_contents() function and how to solve it?
body: <p>I want to get a json array from an API. 
  Why cant I get it using <code>file_get_contents($g_7_14)</code>? </p>
  
  <p>This is the error I get: </p>
  
  <blockquote>
    <p>( ! ) Warning:
    file_get_contents(<a href="https://example.com:443/api/xxx/yyy?app_ids=666&amp;start_date=2015-07-14&amp;end_date=2015-07-14&amp;auth_token=8sCR" rel="nofollow">https://example.com:443/api/xxx/yyy?app_ids=666&amp;start_date=2015-07-14&amp;end_date=2015-07-14&amp;auth_token=8sCR</a>):
    failed to open stream: HTTP request failed! HTTP/1.1 406 Not
    Acceptable in C:\wamp\www\PHPExcel\index.php on line 8</p>
  </blockquote>
  
  <p>and this is my code:</p>
  
  <pre><code>&lt;?php 
  //494792609
  
      if ( !empty ( $_GET['app_id'] ) ) {
          $g_7_14 = 'https://example.com:443/api/xxx/yyy?app_ids=666&amp;start_date=2015-07-14&amp;end_date=2015-07-14&amp;auth_token=8sCR';
          echo $g_7_14.'&lt;br&gt;';
  
          $json_g_7_14 = file_get_contents($g_7_14);
  
          /* $ch = curl_init();
           curl_setopt($ch, CURLOPT_URL,$g_7_14);
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
           curl_setopt($ch,CURLOPT_HTTPHEADER,array('Accept-Encoding: gzip')); 
  
  
           $xml_response = curl_exec($ch);
  
  
          var_dump($xml_response);
          */
  
          $a_g_7_14 = json_decode($json_g_7_14, true);
  
      }
  
  
  
  ?&gt;
  
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;YH &lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form action=""&gt;
      &lt;input type="text" name="app_id" /&gt;
      &lt;button type="submin"&gt; submit&lt;/button&gt;
  &lt;/form&gt;
  
  &lt;div&gt;
  
      &lt;?php 
  
      ?&gt;
  
  &lt;/div&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>You can see in the code I got a cURL part which is commented. Didn't work too :( ! </p>