Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

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:
    151
    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:
    166
    Location:
    Ukraine
    cPanel Access Level:
    Root Administrator
    I'm second here.
    Please tell us how to use XMLAPI within php script.

    Thank you!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. netlink-ie

    netlink-ie Registered

    Joined:
    Sep 29, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    51
    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:
    51
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice