View Source

The following PHP script is used to generate a new license key from the License Pool.


Make sure you specify the following variables:


* Username ({{$USERNAME}})
* Password ({{$PASSWORD}})
* License Pool key ({{$LICENSEPOOLKEY}})
* License type ({{$LICENSETYPE}})
* Number of virtual servers ({{$VIRTUAL_SERVERS}})
* Number of physical servers ({{$PHYSICAL_SERVERS}})





{noformat}
<?php
include 'xmlrpc.inc';
date_default_timezone_set('America/Chicago');

try{
#### User Settings Start ####
## For this example the user should only have to change these settings
$USERNAME = "username";
$PASSWORD = "password";
$LICENSEPOOLKEY = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX";
$LICENSETYPE = "Enterprise Edition (Win)";
$VIRTUAL_SERVERS = '1';
$PHYSICAL_SERVERS = '1';
#### User Settings End ####

#### Common Settings Start ####
$accOwner = $USERNAME;
$accPass = $PASSWORD;
$licPool = $LICENSEPOOLKEY;
#### Common Settings End ####

#### Create Client Start ####
$client = new xmlrpc_client('https://api.r1soft.com/xmlrpc');
$client->setCredentials($accOwner, $accPass);
$client->setSSLVerifyPeer(false);
#### Create Client End ####

#### Make RPC Call Start ####
$xmlrpc_msg = new xmlrpcmsg('licensing.createPooledLicense', array(
new xmlrpcval($LICENSEPOOLKEY, "string"),
new xmlrpcval($LICENSETYPE, "string"),
new xmlrpcval(
array(
"Virtual Servers" => new xmlrpcval($VIRTUAL_SERVERS, "int"),
"Physical Servers" => new xmlrpcval($PHYSICAL_SERVERS, "int")
), "struct"),
),"array"
);
$reply = $client->send($xmlrpc_msg);
#### Make RPC Call End ####

#### Process Reply Start ####
if (!$reply) {
print "Could not connect to HTTP server.";
} elseif ($reply->faultCode()) {
print "XML-RPC Fault #" . $reply->faultCode() . ": " .
$reply->faultString();
} else {
$val = $reply->value();
$arr = php_xmlrpc_decode($val);
print_r($arr);
}
#### Process Reply End ####
}
catch (Exception $ex){
echo "Exception happened \n";
echo $ex;
}

?>
{noformat}

h4. Response Example

Here is an example of a response to the XML-RPC request:

{code}Array (
[Enabled] => 1
[License Pool ID] => 45345345354-345345-345-345-3453453453
[Product] => Enterprise Edition (Win)
[Type] => Pooled License
[Installed] =>
[ID] => 4353453-324234-234-912342312-23423424
[Physical Servers] => 1 ){code}