HI I'm tring to send some headers in my PHP script such as
$headers[] = "BATCH_TYPE: XML_SINGLE";
$headers[] = "VENDOR_ID: 56309";
But they are being received as:
Batch-Type Vendor-ID
..not as they were intended or required - which is causing me problems.
Anyone know why or how to sort?
Thanks,
<?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");
// Activate the POST method
curl_setopt($ch, CURLOPT_POST, 1) ;
// Request
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
curl_setopt($ch, CURLOPT_TIMEOUT, 999);
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;
}
$request_file = "./post_this.xml";
$fh = fopen($request_file, 'r');
$xml_data = fread($fh, filesize($request_file));
fclose($fh);
$url = 'http://www.xhaus.com/headers';
$headers = array();
$headers[] = "Expect:";
$headers[] = "Accept: text/xml";
$headers[] = "BATCH_TYPE: XML_SINGLE";
$headers[] = "BATCH_COUNT: 1";
$headers[] = "VENDOR_ID: 54367";
$Response = httpsPost($url, $xml_data, $headers);
echo $Response;
?>