Client Implementation

Calling the SendCommand() method sends a command to the Master API server. The returned object describes 3 states:

  • the action was successful - the request was fully processed

  • an error occurred - the request cannot be processed; the reason may be a syntax error in the parameters, an attempt to register an already existing domain, and similar cases.

  • a temporary error occurred - the command cannot be completed due to a temporary error condition; in such a case, it is necessary to wait for some time (5 minutes) and send the same command again; WARNING!!! - our automation will not repeatedly attempt to execute the command.

Calling the getMessage() method on the returned object can be used to determine the description of a possible error.

Some command types require parameters. These parameters are based on the e-mail API. The documentation for the e-mail API is here: http://reseller.forpsi.hu/doc/autoregcz_enum.pdf

Certain commands return data (e.g. "list domains"). This data can be obtained using the getData() method. An associative array is returned.

<?php
// execute command
// first parameter: command name (see below in this file)
// second optional parameter: required parameters for the given command
$result = $client->sendCommand("transfer cz domain",array(
    "transfer" =>    "example.cz",
    "auth-info" =>   "kfSkrsmc42",
    "idacc" =>       "PA:PARTNER",
    "iddealer" =>    ""
));
 
// process result
if($result->isSuccess()){
    // success
    echo "command was successfully executed\n";
    echo "--------------------------------\n";
    echo "data:\n";
    print_r($result->getData()); // returns an associative array or null (depending on the response type)
}else{
    // FAILURE!
    // if $this->isTemporaryError() returns true - this is probably a temporary error -> wait 5 minutes and then send the same command again
    echo "command WAS NOT executed successfully\n";
    echo "------------------------------------\n";
    echo "message: ".$result->getMessage()."\n"; // error description
    echo "temporary error: ".($result->isTemporaryError() ? "yes (request should be repeated)" : "no")."\n";
    echo "------------------------------------\n";
    // the following methods can be used for debugging purposes
    // echo "http request:\n";
    // echo $result->getHttpRequest()."\n";
    // echo "http response:\n";
    // echo $result->getHttpResponse()."\n";
}
?>