title: PHP - HTTP Post - incorrect headers
body: <p>Hi I'm currently trying to post an xml file to an external server, but I'm getting a response back that the headers are incorrect. The server I'm posting requires some headers and I'm wondering if they're in the correct format or if there are any other "standard" headers that need to be included?</p>
  
  <p>My code is:</p>
  
  <pre><code>&lt;?php
  
  function httpsPost($Url, $xml_data, $headers)
  {
     // Initialisation
     $ch=curl_init();
     // Set parameters
     curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); 
     curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);    
     curl_setopt($ch, CURLOPT_URL, $Url);
     // Return a variable instead of posting it directly
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch,CURLOPT_USERPWD,"username:password");
     // Active the POST method
     curl_setopt($ch, CURLOPT_POST, 1) ;
     // Request
     curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     // execute the connexion
     $result = curl_exec($ch);
     // Close it
     curl_close($ch);
     return $result;
  }
  
  $headers[0]="BATCH_TYPE: XML_SINGLE"; 
  $headers[1]="BATCH_COUNT: 1"; 
  $headers[2]="VENDOR_ID: 53906";
  
  $request_file = "./post_this.xml"; 
  $fh = fopen($request_file, 'r'); 
  $xml_data = fread($fh, filesize($request_file)); 
  fclose($fh);    
  
  $url = 'http://www.example.com/test.php';
  
  $Response = httpsPost($url, $xml_data, $headers);
  
  echo $Response;
  
  ?&gt;
  </code></pre>