Results 1 to 4 of 4

Thread: PHP XMLAPI Docs

  1. #1
    Member
    Join Date
    Mar 2005
    Posts
    7

    Default PHP XMLAPI Docs

    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. #2
    cPanel Partner NOC cPanel Partner NOC Badge
    Join Date
    May 2003
    Location
    Ukraine
    Posts
    203
    cPanel/WHM Access Level

    Root Administrator

    Default

    I'm second here.
    Please tell us how to use XMLAPI within php script.

    Thank you!
    Regards, Alexey

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    4

    Default 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. #4
    Registered User
    Join Date
    Sep 2007
    Posts
    4

    Default Whm Xml Api

    There is also a PHP class that uses the API. It was developed by Arash Hemmat and can be downloaded here:

    http://www.phpclasses.org/browse/package/4150.html

Similar Threads

  1. PHP xmlapi.php has been updated to version 1.0.11
    By cPanelDavidN in forum cPanel Developers
    Replies: 0
    Last Post: 06-29-2011, 04:12 PM
  2. PHP xmlapi.php has been updated to version 1.0.10
    By cPanelDavidN in forum cPanel Developers
    Replies: 0
    Last Post: 06-27-2011, 03:53 PM
  3. XMLAPI (PHP) Error - Can't add new MX
    By ben-av in forum cPanel Developers
    Replies: 4
    Last Post: 06-10-2010, 02:53 PM
  4. XMLAPI php class
    By MattDees in forum cPanel Developers
    Replies: 108
    Last Post: 10-30-2009, 09:11 AM