root pass and host for xmlapi.php variables?

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
This is pretty straight forward:

root_pass is the root password for the server
remote_host is the ip address/hostname of the server you're attempting to add the account on
domain is the name of the domain you're attempting to add

I do want to point out that this is an obsolete and no longer updated script as noted in the GIT repository homepage here CpanelInc/xmlapi-php
 
  • Like
Reactions: cPanelTJ

cPanelTJ

Product Owner
Staff member
Jan 29, 2019
97
50
93
Houston, TX
cPanel Access Level
Root Administrator
Twitter
Booo,

A more secure and preferred method would be to use our WHM API 1 createacct with a WHM API Token. It would look something like this:

PHP:
<?
    $user = "root";
    $token = "MYAPITOKEN";

    $query = "https://127.0.0.1:2087/json-api/createacct?api.version=1&username=USERNAME&domain=DOMAIN";

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);

    $header[0] = "Authorization: whm $user:$token";
    curl_setopt($curl,CURLOPT_HTTPHEADER,$header);
    curl_setopt($curl, CURLOPT_URL, $query);

    $result = curl_exec($curl);

    $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($http_status != 200) {
        echo "[!] Error: " . $http_status . " returned\n";
    } else {
        $json = json_decode($result);
        echo $json->{'metadata'}->{'reason'};
    }

    curl_close($curl);
?>
 
Last edited:
  • Like
Reactions: cPanelLauren