Man jānosūta xml uz serveri un tad attiecīgi serveris atgriež man xml, bet kautkas man te nestrādā, jo visu laiku met ārā "Bad Request - Invalid URL"
Te būs mans kods:
$url = "http://www.domeens.com";
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<Request>
<Tags>blah blah</Tags>
</Request>';
$header = "POST HTTP/1.1 \r\n";
$header .= "Content-type: text/xml \r\n";
$header .= "Content-length: ".strlen($xml)." \r\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
$data = curl_exec($ch);
if(curl_errno($ch))
print curl_error($ch);
else
curl_close($ch);
echo $data;
Lai viss parezi darbotos, šāds ir servera nosacījumi:
- Requests to the server should be sent as XML over HTTP 1.1
- The request type should be POST;
- A Content-Length header should be present, and the total length of the request should be below 16KB;
- A Content-Type header should be present, containing the media type value text/xml;