The API functions are designed only for Master Resellers to perform operation on their resellers
API URL : http://serverip:2082/frontend/x3/master/api.php?type=json , where x3 is the cPanel theme of the account.The output will be json encoded string if type=json is provided. Otherwise it will show as XML page.
Method : POST or GET
Required values : cPanel username, ServerIP/domain, cPanel password.
Conditions : The user must have Reseller as well as Master Reseller permission
Connect to WHM XML API and get user's cPanel theme
Connect to cPanel WHMPHP api and call the function
Example Usage ( PHP code ) Download now
<?php
$serverip ="127.0.0.1" ; // Server IP address of domain name if the domain is pointed to the server
$cpanel_username = "master" ; // cPanel username
$cpanel_password = "mypass" ; // cPanel password
$output = json_decode(connect("whm","/json-api/accountsummary?user=$cpanel_username"),true);
$theme = $output['acct'][0]['theme']; // we got the theme of the account
$request = "/frontend/$theme/master/api.php?type=json&action=listresellers";
// If you want to get XML style output, remove type=json from above and change the below codes accordingly
$output = json_decode(connect("cpanel",$request),true);
// Here, the $output contains the list of resellers
// To print it use foreach
foreach($output['reseller'] as $reseller)
echo $reseller . "<br>";
// ends
// You can execute all the calls like this fashion.
// Function to connect to both whm and cpanel. No editing is required
function connect($type,$request)
{
global $serverip,$cpanel_password,$cpanel_username;
$ch = curl_init (); // Initiate curl
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
if($type=="whm")
curl_setopt ($ch, CURLOPT_URL, '' . 'https://' . $serverip . ':2087' . $request);
else
curl_setopt ($ch, CURLOPT_URL, '' . 'https://' . $serverip . ':2083' . $request);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$authstr = 'Basic ' . base64_encode ($cpanel_username . ':' . $cpanel_password);
$curlheaders[0] = '' . 'Authorization: ' . $authstr;
curl_setopt ($ch, CURLOPT_HTTPHEADER, $curlheaders);
$data = curl_exec ($ch);
curl_close ($ch);
return $data ;
}
?>
For WHMCS Module please refer this page
Create Reseller
| Input | action | createreseller |
| domain | Doman name of reseller | |
| username | Username of reseller | |
| password | Password of reseller | |
| Email Address of reseller | ||
| package | Package Name | |
| Output | ||
| statumsg | Normal cPanel account creation messages | |
| status | 0/1 |
List Resellers
| Input | action | listresellers |
| Output | ||
| reseller | list of resellers |
Suspend Reseller
| Input | username | Username of reseller* |
| action | suspendreseller | |
| Output | ||
| statumsg |
|
|
| status | 0/1 |
Unsuspend Reseller.
| Input | username | Username of reseller* |
| action | unsuspendreseller | |
| Output | ||
| statumsg |
|
|
| status | 0/1 |
Terminate Reseller
| Input | username | Username of reseller* |
| action | terminatereseller | |
| Output | ||
| statumsg |
|
|
| status | 0/1 |
Change Reseller Password
| Input | username | Username of reseller* |
| password | New password | |
| action | changepwd | |
| Output | ||
| statumsg |
|
|
| status | 0/1 |
Set Limits and Overselling
| Input | username | Username of reseller* |
| action | setlimit | |
| limit | Interger | |
| band | Interger | |
| disk | Interger | |
| oversell_disk | Boolen ( 0 - disable , 1 - enable ) | |
| oversell_bw | Boolen ( 0 - disable , 1 - enable ) | |
| ns1 | String | |
| ns2 | String | |
| Output | ||
| statumsg |
|
|
| status | 0/1 |
