Sunday, 19 April 2015

PHP curl is not working



I am working on Flight APi of arzoo and using Php Curl to get the data from the server.I have used answer provided in this question (Send XML data to webservice using php curl didn't work for me.



$input_xml = '<AvailRequest>
<Trip>ONE</Trip>
<Origin>BOM</Origin>
<Destination>JFK</Destination>
<DepartDate>2013-09-15</DepartDate>
<ReturnDate>2013-09-16</ReturnDate>
<AdultPax>1</AdultPax>
<ChildPax>0</ChildPax>
<InfantPax>0</InfantPax>
<Currency>INR</Currency>
<PreferredClass>E</PreferredClass>
<Eticket>true</Eticket>
<Clientid>xxx</Clientid>
<Clientpassword>xxxx</Clientpassword>
<Clienttype>ArzooFWS1.1</Clienttype>
<PreferredAirline>AI</PreferredAirline>
</AvailRequest>';


PHP code



$ch = curl_init();
$url = "http://ift.tt/1D6Gkug";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"xmlRequest=" . $input_xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300);
$data = curl_exec($ch);
curl_close($ch);
$array_data = json_decode(json_encode(simplexml_load_string($data)), true);

print_r('<pre>');
print_r($array_data);
print_r('</pre>');


the result of print_r is strange and i cant understand it.



Array
(
[@attributes] => Array
(
[targetNamespace] => http://ift.tt/1JXJXZ8
)

)

No comments:

Post a Comment