PHP Classes

using cPanel API2 functions

Recommend this page to a friend!

      WHM XML API  >  All threads  >  using cPanel API2 functions  >  (Un) Subscribe thread alerts  
Subject:using cPanel API2 functions
Summary:This is the way you can use Cpanel API2 functions
Author:Arash Hemmat
Date:2007-09-29 19:33:45
Update:2011-02-16 18:46:30

  1. using cPanel API2 functions   Reply   Report abuse  
Arash Hemmat - 2007-09-29 19:33:45
If you need to use the Cpanel API2 functions you can make a function like the one below and add it to the class:

* cPanel API2 Cpanel::Email::listpopswithdisk
* This function lists all email accounts for a domain, along with their disk space quota and disk space usage.
function Email_listpopswithdisk($user,$domain)
//connect using prpoer xml api address
//get the output
$this->errors[]='No output.';
return false;

//get the output xml as an array using simple xml
$xml = new SimpleXMLElement($xmlstr);
foreach($xml->data as $entry)
$result[$i]['domain']=htmlentities((string) $entry->domain);
$result[$i]['user']=htmlentities((string) $entry->user);
$result[$i]['login']=htmlentities((string) $entry->login);
$result[$i]['email']=htmlentities((string) $entry->email);
$result[$i]['_diskquota']=htmlentities((string) $entry->_diskquota);
$result[$i]['_diskused']=htmlentities((string) $entry->_diskused);
$result[$i]['diskquota']=htmlentities((string) $entry->diskquota);
$result[$i]['diskused']=htmlentities((string) $entry->diskused);
$result[$i]['diskusedpercent']=htmlentities((string) $entry->diskusedpercent);
$result[$i]['diskusedpercent20']=htmlentities((string) $entry->diskusedpercent20);
$result[$i]['humandiskquota']=htmlentities((string) $entry->humandiskquota);
$result[$i]['humandiskused']=htmlentities((string) $entry->humandiskused);
$result[$i]['txtdiskquota']=htmlentities((string) $entry->txtdiskquota);
return $result;
$this->errors[]='Some errors occured.';
return false;

Usage of this function is just like the other functions in class:

//include the whm class file.

// create a new instance of whm class
$test= new whm;

//initilize the whm object
//you can use you hostname or an IP below
//you can find you whm hash when yopu login into your whm account clickong on "Setup Remote Access Key" link.


  2. Re: using cPanel API2 functions   Reply   Report abuse  
ratul kislaya - 2011-02-16 18:46:31 - In reply to message 1 from Arash Hemmat

I am sending this in a big hope for a solution from you :)

I have two problems and searched everywhere in google and the forums I couldn't find an answer. However this seems pretty basic so I must be doing something wrong or thinking something wrong. Please guide.

1. What is the API to create a feature list on WHM (preferably API2)
2. While creating a Package, the addpkg API call, refers to an input variable 'featurelist (string) Name of the feature list to be used for the package.'. In the example I see that the word 'Default' is passed indicating that a featurelist name has to be passed, which matches the documentation description. How to get this featurelist string names???

The API Listed at getfeaturelist does not help.

Please help