title: PHP server side post
body: <p>I am trying to get a server side POST to work in PHP. I am trying to send transaction data to a payment gateway but I keep getting the following error:</p>
  
  <blockquote>
    <p>Message: <code>fopen(https://secure.ogone.com/ncol/test/orderstandard.asp)</code>: failed to open stream: HTTP request failed! HTTP/1.1 411 Length Required </p>
  </blockquote>
  
  <p>Code:   </p>
  
  <pre><code>$opts = array(
      'http' =&gt; array(
          'Content-Type: text/html; charset=utf-8',
          'method' =&gt; "POST",
          'header' =&gt; "Accept-language: en\r\n" .
          "Cookie: foo=bar\r\n"
       )
  );
  
  $context = stream_context_create($opts);
  
  $fp = fopen('https://secure.ogone.com/ncol/test/orderstandard.asp', 'r', false, $context);
  fpassthru($fp);
  fclose($fp);
  </code></pre>
  
  <p>Tried a few solutions found online - mostly shots in the dark so no luck so far!</p>