So I am trying to pass an xml string through curl onto a server. Currently what I am getting back is:
XML Parsing Error: not well-formed
if I turn off header type setting it to 'Content-type: text/xml' so now its just text/plain, i get:
415 Unsupported Media Type
I have gone through my xml string and tested seperatly to make sure the string I passing is good. It is, assigning the string as text/xml will produce a valid xml page without any errors. so it seems that my curl setup is to blame for this.
here is my code:
PHP Code:
$xmlToSend = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order xmlns="http://sandbox.plimus.com">
<soft-descriptor>DescTest</soft-descriptor>
<ordering-shopper>
<credit-card>
<card-last-four-digits>'.$cardLastFour.'</card-last-four-digits>
<card-type>'.$cardType.'</card-type>
</credit-card>
<shopper-id>'.$shopperId.'</shopper-id>
<web-info>
<ip></ip>
<remote-host>bzq-219-121-253.static.bezeqint.net.reinventhosting.com</remote-host>
<user-agent>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.3; .NET CLR 2.0.50727)</user-agent>
<accept-language>en-us</accept-language>
</web-info>
</ordering-shopper>
<cart>
<cart-item>
<sku>
<sku-id>'.$skuId.'</sku-id>
</sku>
<quantity>1</quantity>
</cart-item>
</cart>
<expected-total-price>
<amount>'.$amount.'</amount>
<currency>'.$currency.'</currency>
</expected-total-price>
</order>
';
//echo $xmlToSend;
$ch = curl_init();
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_USERPWD, $credentials);
curl_setopt($ch, CURLOPT_URL, 'https://domain.com');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlToSend);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
all the variables in the code have values assigned to them, so dont worry about that part
Any ideas on what I am missing would be greatly appreciated