Hello,
I'm trying to get webservice response in xml format. I'm getting the response but it's not in xml. It's just text.
Can someone please look at the code ?
<?php
$targeturl="https://api.com";
$DevKey= "xxxxx";
// return xml feed
$ch = curl_init($targeturl);
curl_setopt($ch, CURLOPT_POST, FAlSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: '.$DevKey));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($ch);
$xml = new SimpleXMLElement($response);
curl_close($ch);
echo $response; // will print in browser all country codes in an xml format
/*
ADD YOUR OWN CODE HERE TO DO WHAT YOU WANT WITH THE RESPONSE. MAYBE SAVE RESULTS TO A FILE OR THE PARSE THE RESULTS INTO A DATABASE?
*/
?>