I am a new developer and I have this simple xml web service to call: http://54.225.189.16/UACServices/GSaaS.asmx?op=validateUser
The problem I have is that it is on another domain so I have to find a way to work it out, could anyone help?
I am a new developer and I have this simple xml web service to call: http://54.225.189.16/UACServices/GSaaS.asmx?op=validateUser
The problem I have is that it is on another domain so I have to find a way to work it out, could anyone help?
You’ll need to call it with cURL.
I used this function when I encountered a similar situation a couple years back.
/**
* load XML file using cURL from outside URL
* if cURL is not available, this defaults to using simplexml_load_file()
* @param string $url
*/
function simplexml_load_file_curl($url) {
$xml="";
if(in_array('curl', get_loaded_extensions())){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$xml = simplexml_load_string(curl_exec($ch));
curl_close($ch);
}
else{
$xml = simplexml_load_file($url);
}
return $xml;
}
$xml = simplexml_load_file_curl('http://example.org/xml-file-url.xml');
Then just treat it as a SimpleXMLElement: http://www.php.net/manual/en/class.simplexmlelement.php