title: How to send Accept Encoding header with fopen in PHP
body: <p>I have an API that returns results after being sent POST data.</p>
  
  <p>Currently I am using fopen.</p>
  
  <p>I am told that when sent the correct header, the API will return gzip compressed results.</p>
  
  <p>How do I send the Accept Encoding header with fopen?</p>
  
  <p>Currently, the relevant code looks like:</p>
  
  <pre><code>  $params = array('http' =&gt; array( 
       'method' =&gt; 'POST',
       'content' =&gt;  $xml,
       'header'  =&gt; 'Content-type: application/x-www-form-urlencoded' . "\r\n",
       'ignore_errors' =&gt; $ignoreErrors
    )); 
  
    $ctx = stream_context_create($params); 
    $fp = fopen($url, 'rb', false, $ctx);
  </code></pre>
  
  <p>All the examples / etc that are easily found in Google relate to people trying to read streams that are always gzip compressed or people looking to set the header so they can send compressed data.</p>