The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Select only necessary information

Discussion in 'cPanel Developers' started by vivekvsist, Feb 7, 2009.

  1. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    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 ?
     
  2. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Anybody here for a help ?
     
  3. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
  4. gamesguru

    gamesguru Member

    Joined:
    Nov 25, 2008
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    1
    How did you get this working?

    Please Tell!
     
Loading...
Similar Threads - Select necessary information
  1. samend
    Replies:
    1
    Views:
    476

Share This Page