cPanelLicensing PHP Class
Last modified: 2022 July 27
Overview
The cPanelLicensing PHP class runs Manage2 API functions. You can use this to manage customer licenses from the command line or through the Manage2 user interface.
- The
cPanelLicensingPHP class requires PHP 5 with cURL and SimpleXML support. PHP 5 enables SimpleXML support by default. - SimpleXML transforms XML into data structures that are similar to associative arrays.
- The
cPanelLicensingPHP class returns SimpleXML objects by default, or can return XML, JSON, or YAML.
Download the module
To download the cPanelLicensing PHP class, click the cPanel License Management API SDK link in the Automation menu on the Manage2 Dashboard interface.
Basic use
The following script uses the cPanelLicensing PHP class to call the Manage2 List License Information function:
|
|
Include the cPanelLicensing class
Line 2 uses PHP’s include() statement to include and evaluate the cPanelLicensing class:
|
|
Instantiate the cPanelLicensing object
Line 4 instantiates the cPanelLicensing object, which provides the script with access to the cPanelLicensing object’s functions:
|
|
Include the following variables when you instantiate the cPanelLicensing object:
username— The user’s username.password— The user’s password.
Call a function
Line 8 defines an array of the function’s input parameters. Line 11 calls the Manage2 List License Information function and passes the array as an argument:
|
|
You can also perform this action in one step:
|
|
Methods
The cPanelLicensing PHP class includes the following methods:
The set_format method
Use the set_format method to choose the PHP class’s output type. By default, the class returns a SimpleXML object.
$cpl->set_format("json");The set_format method accepts a single parameter with one of the following string values:
simplexml— Return SimpleXML.xml— Return XML.json— Return JSON.yaml— Return YAML.
The findKey method
This method only operates in SimpleXML mode.
Use the findKey method to retrieve a group or package name.
|
|
This function accepts two parameters: search and package SimpleXML objects.