Created
January 12, 2010 10:05
-
-
Save up1/275078 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function responseXML($url ='',$post_data ='', $parse=false){ | |
$ch = curl_init(); //initiate the curl session | |
curl_setopt($ch, CURLOPT_URL, $url); //set to url to post to | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // tell curl to return data ina variable | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); // post the xml | |
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // set timeout in seconds | |
$xmlResponse = curl_exec ($ch); | |
if (curl_errno($ch)) { | |
print curl_error($ch); | |
} else { | |
curl_close($ch); | |
} | |
if(!$parse){ | |
return $xmlResponse; | |
}else { | |
$aData = array(); | |
if(trim($xmlResponse)!=""){ | |
$dom = new DOMDocument; | |
$dom->loadXML($xmlResponse); | |
$this->readXml($dom , $aData); | |
} | |
return $aData; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment