Hello
I am new to this XML- API calls. Never used before. I did a couple of searches here before posting. Gathered some information, but need lot more.
Here is the code what I am using for my first need.
Code:<?php $host = "localhost"; $user = "root"; $accesshash = "[ACCESSHASH]"; header( "Content-type: application/xml" ); $request = "/xml-api/accountsummary?user=${user}"; $cleanaccesshash = preg_replace("'(\r|\n)'","",$accesshash); // Change 'root' to reseller username as required $authstr = "root:" . $cleanaccesshash; $cpanelaccterr = ""; $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0); curl_setopt($ch, CURLOPT_URL, "https://${host}:2087" . $request); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $curlheaders[0] = "Authorization: WHM $authstr"; curl_setopt($ch,CURLOPT_HTTPHEADER,$curlheaders); $data=curl_exec ($ch); curl_close ($ch); echo $data; ?>
I never tried anything with XML files, So I dont know how to arrage the result.
I am using PHP for my coding.
Here is the sample result I am getting.
Code:<accountsummary> − <acct> <disklimit>unlimited</disklimit> <diskused>581M</diskused> <domain>domain.com</domain> <email>*unknown*</email> <ip>IP address</ip> <owner>username</owner> <partition>home</partition> <plan>package_name</plan> <startdate>07 Aug 25 02:55</startdate> <suspended>0</suspended> <suspendreason>not suspended</suspendreason> <theme>xpevolution</theme> <unix_startdate>1188028514</unix_startdate> <user>user</user> </acct> <status>1</status> <statusmsg>Ok</statusmsg> </accountsummary>
I just want to display the username as well as domain name using my php code.
like
$username = xml_array(<username>)
echo $username
But I am not sure how can I extract the username form the above output using php
Anyone can help me ?



LinkBack URL
About LinkBacks
Reply With Quote





