PHP
partner10.createKey()
<?php
#
# This example uses Zend Framework 1 that can be downloaded from http://framework.zend.com/downloads/latest#ZF1
#
# Uncomment and edit these lines if necessary:
#set_include_path('/root/lib/ZendFramework-1.12.1-minimal/library' . PATH_SEPARATOR . get_include_path()); # add Zend Framework to include path
#@date_default_timezone_set(date_default_timezone_get());
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
## Auth Settings
$apiUrl = 'https://ka.demo.plesk.com:7050/xmlrpc';
$apiLogin = 'API_LOGIN';
$apiPassword = 'API_PASSWORD';
## Call Details:
$clientLogin = 'CLIENT_LOGIN';
$licenseType = 'billing';
$mainKeyType = 'PLESK_10_AND_LATER';
$mainKeyFeatures = array(
new Zend_XmlRpc_Value_String('UNLIMITED_DOMAINS'),
new Zend_XmlRpc_Value_String('UNLIMITED_LANGUAGE_PACKS'),
);
$mainKeyCreationParameters = array();
$additionalKeyTypes = array(
new Zend_XmlRpc_Value_String('PLESK_ANTIVIRUS_BY_KAV'),
);
$additionalKeysCreationParameters = array();
$serverAddress = new Zend_XmlRpc_Value_Struct(array(
'ips' => new Zend_XmlRpc_Value_Array(array(new Zend_XmlRpc_Value_String('192.168.0.1'))), # put your IPs here
'macs' => new Zend_XmlRpc_Value_Array(array()), # put your MACs here
));
# Prepare the necessary structures:
$authInfo = new Zend_XmlRpc_Value_Struct(array(
'login' => new Zend_XmlRpc_Value_String($apiLogin),
'password' => new Zend_XmlRpc_Value_String($apiPassword),
));
$callParameters = array(
$authInfo,
$serverAddress,
new Zend_XmlRpc_Value_String($clientLogin),
new Zend_XmlRpc_Value_String($mainKeyType),
new Zend_XmlRpc_Value_Array($mainKeyFeatures),
new Zend_XmlRpc_Value_Struct($mainKeyCreationParameters),
new Zend_XmlRpc_Value_Array($additionalKeyTypes),
new Zend_XmlRpc_Value_Struct($additionalKeysCreationParameters),
new Zend_XmlRpc_Value_String( $licenseType )
);
# Make a call:
$api = new Zend_XmlRpc_Client($apiUrl);
$api->setSkipSystemLookup();
$result = $api->call('partner10.createKey', $callParameters);
if (100 != $result['resultCode']) {
echo "Failed to create a key: {$result['resultDesc']}\n";
}
else {
$keyNumber = $result['mainKeyNumber'];
$additionalKeyNumbers = implode(', ', $result['additionalKeysNumbers']);
echo "A new key has been created. The key number is {$keyNumber}.\n";
echo "Additional key numbers are {$additionalKeyNumbers}.\n";
}
?>
partner10.retrieveKey()
<?php
#
# This example uses Zend Framework 1 that can be downloaded from http://framework.zend.com/downloads/latest#ZF1
#
# Uncomment and edit these lines if necessary:
#set_include_path('/root/lib/ZendFramework-1.12.1-minimal/library' . PATH_SEPARATOR . get_include_path()); # add Zend Framework to include path
#@date_default_timezone_set(date_default_timezone_get());
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
## Auth Settings
$apiUrl = 'https://ka.demo.plesk.com:7050/xmlrpc';
$apiLogin = 'API_LOGIN';
$apiPassword = 'API_PASSWORD';
## Call Details:
$keyNumber = "PLSK.00052355";
# Prepare the necessary structures:
$authInfo = new Zend_XmlRpc_Value_Struct(array(
'login' => new Zend_XmlRpc_Value_String($apiLogin),
'password' => new Zend_XmlRpc_Value_String($apiPassword),
));
$callParameters = array(
$authInfo,
new Zend_XmlRpc_Value_String($keyNumber)
);
# Make a call:
$api = new Zend_XmlRpc_Client($apiUrl);
$api->setSkipSystemLookup();
$result = $api->call('partner10.retrieveKey', $callParameters);
if (100 != $result['resultCode']) {
echo "Failed to retrieve a key: {$result['resultDesc']}\n";
}
else {
echo "Retrieved the key {$keyNumber}:\n";
echo "\n{$result['key']}\n";
}
?>
partner10.sendKeyByEmail ()
<?php
#
# This example uses Zend Framework 1 that can be downloaded from http://framework.zend.com/downloads/latest#ZF1
#
# Uncomment and edit these lines if necessary:
#set_include_path('/root/lib/ZendFramework-1.12.1-minimal/library' . PATH_SEPARATOR . get_include_path()); # add Zend Framework to include path
#@date_default_timezone_set(date_default_timezone_get());
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
## Auth Settings
$apiUrl = 'https://ka.demo.plesk.com:7050/xmlrpc';
$apiLogin = 'API_LOGIN';
$apiPassword = 'API_PASSWORD';
## Call Details:
$keyNumber = "PLSK.00052355";
$zipped = 1; # send key compressed/zipped
# Prepare the necessary structures:
$authInfo = new Zend_XmlRpc_Value_Struct(array(
'login' => new Zend_XmlRpc_Value_String($apiLogin),
'password' => new Zend_XmlRpc_Value_String($apiPassword),
));
$callParameters = array(
$authInfo,
new Zend_XmlRpc_Value_String($keyNumber),
new Zend_XmlRpc_Value_Boolean($zipped)
);
# Make a call:
$api = new Zend_XmlRpc_Client($apiUrl);
$api->setSkipSystemLookup();
$result = $api->call('partner10.sendKeyByEmail', $callParameters);
if (100 != $result['resultCode']) {
echo "Failed to send the key by e-mail: {$result['resultDesc']}\n";
}
else {
echo "The key {$keyNumber} was sent by e-mail.\n";
}
?>