| The Cube Panelīs API 2.2 Reference Guide: Accessing Cube Panel's WebServices | ||
|---|---|---|
| Prev | Chapter 1. Introduction | Next |
The WSAccess class allows you to establish a connection with the Cube Panel in order to obtain other user's credentials. The definitions of the class constructor are as follows:
WSAccess(user_name, password, host, port, id_language)
user_name : The user with maximum privileges with whom the connection is to be established
password : User password.
host : Cube Panel server IP/Name to be used.
port : Cube Panel server port (default 25112).
id_language : Language ID for the search results (1 - Spanish, 2 - English, 3 - German, 4 - French, 5 - Portuguese).
The user assigned as the constructor of the function is who shall determine the applicable maximum privileges in using the WebServices. If the user is "admin", it may access any WebService of any client or domain. If user is a client, it may only act within its client services and domains.
Before using any WebServices, the user needs to obtain user credentials with which it will access the WebServices. For this, the WSAccess class uses the getUser method that receives a request from a WSUser, which is necessary to use the WebServices. The function has the following definitions:
WSUser getUser(effective_user)
The effective_user parameter corresponds to the username of whoever is interested in the access.
With WSUser any WebService can be accessed with the execute method:
mixed execute(method_name, params)
method_name : Name of the WebService to be executed
params : array with the necessary parameters for the WebService
The following example demonstrates how to access the WebServices as administrator or as client:
// Init access object
$access = new WSAccess('admin', 'admin_pass', 'server', 25112);
// Get admin user
$admin_user = $access->getUser('admin');
// Get one client user
$client_user = $access->getUser('client1');
// Get one domain user
$domain_user = $access->getUser('domain-cubews.com');
// Get server client list
$clients_list = $admin_user->execute('ADMINCLIENTS_getClients',array());
// Get server domain list
$domains_list = $client_user->execute('DOMAINS_getDomains',array());
// Get ftp accounts of domain-cubews.com
$ftp_accounts = $domain_user->execute('FTP_listUsers',array());