API documentation


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 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
  • The reseller has been suspended
  • This account is locked. Please contact system administrator
  status 0/1

Unsuspend Reseller.

Input username Username of reseller*
  action unsuspendreseller
     
Output    
  statumsg
  • The reseller has been unsuspended
  • This account is locked. Please contact system administrator
  status 0/1

Terminate Reseller

Input username Username of reseller*
  action terminatereseller
     
Output    
  statumsg
  • The reseller has been removed
  • You can not terminate your own account
  status 0/1

Change Reseller Password

Input username Username of reseller*
  password New password
  action changepwd
Output    
  statumsg
  • The password has been changed successfully
  • The password may not contain the username for security reasons
  • Password must be at least 5 characters
  • The user does not exist
  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
  • Limit Set
  status 0/1

 

 


ABOUT US

WHMPHP A software by Zend Software Private Limited.
Contact support@whmphp.com , Terms of Service

CONTACTS

If you have a new idea to tell us, or just need to hear a friendly voice feel free to contact us anytime.

Switch Language