Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

The cPanel::Accounting Perl Module

The Cpanel::Accounting Perl module provides an object oriented interface to a variety of WHM functions. The XML-API should be used in place of the Accounting modules. The Accounting modules are provided for legacy purposes only (pre-cPanel 11.23).

ALERT! Warning: Do not use this Perl module if you are running cPanel 11.23 or later.

This module can be found in /usr/local/cpanel/Cpanel.

Functions

new(hash)

This function instantiates the Cpanel::Accounting module.

note Note: All of these parameters can be accessed via the class by modifying $class->{'param'}.

Parameters

  • host (string) — The host to which the module will authenticate.
  • user (string) — The user to authenticate as
  • accesshash (hash) — Remote access key to use for authentication
  • timeout (integer) — Specifies the connection timeout
  • usessl (boolean) — Specifies whether or not the connection should be encrypted by SSL.

Example

my $accounting = Cpanel::Accounting->new(
        host => "localhost",
        user => "root",
        accesshash => $accesshash
);

killpkg(pkg)

This function removes the specified package.

Parameters

  • pkg (string) — The name of the package you wish to remove.

suspend(user)

This function suspends a specified user's account.

Parameters

  • user (string) — The username to be suspended.

unsuspend(user)

This function unsuspends a specified user's account.

Parameters

  • user (string) — The username corresponding to the account that you wish to unsuspend.

killacct(user)

This function removes an account.

Parameters

  • user (string) — The username corresponding to the account you wish to remove.

showversion()

This function returns the version of cPanel the server running.

showhostname()

This function returns the hostname of the server.

createacct(domain, username, password, plan, language)

This function allows you to create an account.

Parameters

  • domain (string) — The main domain assigned to the account.
  • username (string) — The username for the account.
  • password (string) — The new account's password.
  • plan (string) — The plan assigned to the account.
  • language (string) — The language the new account will use.

listpkgs()

This function returns a list of packages.

listaccts()

This function returns a list of accounts on the server.

api1(username, apiversion, module, function, args)

This function allows you to perform an API1 call.

Parameters

  • username (string) — The cPanel username that the API 1 call will affect.
  • apiversion (integer) — This parameter should always be 1.
  • module (string) — The module of the API1 function to be executed.
  • function (string) — The API function to be executed.
  • args (array) — An array of arguments to be passed to the API call.
    • PICK Remember: args is an optional parameter.

api2(username, apiversion, module, function, key1, value1, keyn, valuen)

This function allows you to perform an API2 call.

Parameters

  • username (string) — The user of the cpanel account to execute the API2 call against
  • apiversion (integer) — This should always be 2.
  • module (string) — The module of the API2 function to be executed.
  • function (string) — The API2 function to be executed
  • key — This is the key for the API2 parameter to be sent.
    • PICK Remember: This parameter is optional.
  • value — This is the value for the API2 parameter to be sent.
    • PICK Remember: This parameter is optional.

note Note: Both key and value can be repeated as many times as needed.

Topic revision: r7 - 18 Feb 2011 - 23:00:14 - Main.JustinSchaefer