PHP

For PHP, we recommend the Pear package XML_RPC. You can download it at http://pear.php.net/package/XML_RPC/. It will handle the https connection transparently.

  1. Load the XML_RPC class.

    require_once("XML/RPC.php"); # PEAR::XML-RPC class

  2. Define variables. Be aware to use https in the URL part.

    $login = "apilogin"; # username for API

    $password = "apipassword"; # password for API

    $key = "PLSK.00052355"; # key to retrieve

    $url = "https://ka.parallels.com";

    $port = 7050;

    $functionName = "partner10.retrieveKey"

  3. Create method parameter structs. AuthInfo struct consists of two entities (login, passport). The main function has two parameters, we store them in the array $functionParams[].

    $AuthInfo["login"] = new XML_RPC_VALUE($login, "string");

    $AuthInfo["password"] = new XML_RPC_VALUE($password, "string");

    $functionParams[] = new XML_RPC_VALUE($AuthInfo, "struct");

    $functionParams[] = new XML_RPC_VALUE($key, "string");

  4. Create message object. This bundles the complete XML-RPC request.

    $message=new XML_RPC_Message($functionName,$functionParams);

  5. Establish connection to KA server.

    $client = new XML_RPC_Client("/", $url, $port);

  6. Send request to server. Store the response object in $result variable. Then extract the XML data to the $data variable.

    $result = $client->send($message);

    $data = $result->value();

  7. Convert the XML data to a named array.

    $dataArray = XML_RPC_decode($data);

  8. Check the response code. Process the data if the call was successful, else perform some error handling. You can find the current key number e.g. in $dataArray["keyNumber"], the actual key file is in $dataArray["key"]. The key file is encoded in BASE64, so you still need to decode it.

    if ($dataArray["resultCode"] == 100) {

    Process data here!

    echo $dataArray["key"]; # prints key

    # print_r($dataArray); # print the entire array

    } else {

    echo "Result Code: ".$dataArray["resultCode"]."\n";

    echo "Result Desc: ".$dataArray["resultDesc"].$dataArray["faultString"]."\n";

    }

Now you can process the Key file, store it on a file system or in a database. Or directly install it in the software.