My question is, to use CURL does it need to be installed on the server your sending the request to, or just on your server?
Also is there anything that can stop fsockopen from working in a server setup? As the example files they have given me don't seem to work when tested. I'm trying to work out where the issue is as the xml i'm sending is the xml they provide with our details inserted.
When using the example php script I get the following error:
The script itself is :Your browser sent a request that this server could not understand.
Request header field is missing ':' separator.
<OnlineCheck>
Code: Select all
<?php
// First we need to feed the techdata SKU, for now we use 1088963 as an example
$td_sku='123456';
//Following the XML data
$xmldata="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r
<OnlineCheck>\r
<Header>\r
<BuyerAccountId>123123</BuyerAccountId>\r
<AuthCode>code here</AuthCode>\r
<Type>Full</Type>\r
</Header>\r
<Item line=\"1\">\r
<ManufacturerItemIdentifier/>\r
<ResellerItemIdentifier/>\r
<DistributorItemIdentifier>$td_sku</DistributorItemIdentifier>\r
<Quantity>1</Quantity>\r
</Item>\r
</OnlineCheck>";
echo '<pre>'.$xmldata.'</pre>';
//Test
$fp = fsockopen("url", 8080, $errno, $errstr, 15);
//Generate the postdata on a valid way, $out4 needs to be calculated, so will be later.
$out1 = "POST /Onlchk HTTP/1.0\r";
$out2 = "Content-Type: multipart/form-data;\r boundary=---------------------------2\r";
$out3 = "Host: intcom.xml.quality.techdata.de:8080\r";
$out5 = "Connection: close\r\r";
$out6 = "-----------------------------2\r";
$out7 = "Content-Disposition: form-data; name=\"onlinecheck\"\r\r";
$out8 = "\r-----------------------------2--";
//Calculation of the Content-Length:
$tlen=strlen($out6)+strlen($out7)+strlen($xmldata)+strlen($out8);
$out4 = "Content-Length: $tlen\r";
//Generate full output
$out = $out1.$out2.$out3.$out4.$out5.$out6.$out7.$xmldata.$out8;
fwrite($fp, $out);
$retval = "";
while(!feof($fp)){$retval = "$retval".fgets($fp,128);}
fclose($fp);
$xmlResponse = $retval;
echo '<pre>'.$retval.'</pre>';
list($headers,$body) = explode("<?xml version=\"1.0\" encoding=\"UTF-8\"?>",$retval);
$doc = new DOMDocument;
$doc = LoadXML($body);
echo $body;
?>
Thanks