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.

PHP XMLAPI Docs

Discussion in 'cPanel Developers' started by dquinney, Feb 14, 2007.

  1. dquinney

    dquinney Member

    Joined:
    Mar 20, 2005
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Does anyone have any PHP code to use with the the new XMLAPI? Any help would be much appreciated.

    Regards Dan
    www.hostingme.co.uk
     
  2. AlexAT

    AlexAT Well-Known Member
    PartnerNOC

    Joined:
    May 23, 2003
    Messages:
    203
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Ukraine
    cPanel Access Level:
    Root Administrator
    I'm second here.
    Please tell us how to use XMLAPI within php script.

    Thank you!
     
  3. netlink-ie

    netlink-ie Registered

    Joined:
    Sep 29, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    cPanel API and PHP

    Here is an example of how you could use the API with PHP:

    <?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;

    ?>
     
  4. netlink-ie

    netlink-ie Registered

    Joined:
    Sep 29, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
Loading...

Share This Page