Jump to content

Read an array of xml responses


nuwaninfo

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.