nuwaninfo Posted March 16, 2009 Share Posted March 16, 2009 Hi, I am using an API to get some response. It returns an array of 2 xml responses. I have tried to use PHP DOM XML. But it did not work. Below is my code, $url = "url"; # URL to WHMCS API file $whmcsadminusername= "username"; # Admin username goes here $whmcsadminpassword= "password"; # Admin password goes here $postfields["username"] = $whmcsadminusername; $postfields["password"] = md5($whmcsadminpassword); $postfields["action"] = "getclientsproducts"; $postfields["clientid"] = "290"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch); /* $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $data = curl_exec($ch); curl_close($ch);*/ $data = explode(";",$data); foreach ($data AS $temp) { $temp = explode("=",$temp); $results[$temp[0]] = $temp[1]; } //print_r($data); echo '<pre>' . print_r($results, true) . '</pre><br /><br />'; And here is the link to the site. http://www.superquicksite.com/test_api.php Here is the documentation of that API, http://wiki.whmcs.com/API:Get_Clients_Products I would be much appriciate your help. Thank you. Link to comment https://forums.phpfreaks.com/topic/149632-read-an-array-of-xml-responses/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.