PHP code example of yarri / master-api-client

1. Go to this page and download the library: Download yarri/master-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yarri / master-api-client example snippets


   

  $client = new MasterApi_Client(array(
    "username" => "GR:PLATCE",        // prihlasovaci jmeno platce (idacc nebo iddealer)
    "password" => "heslo",            // heslo platce
    "charset" => "UTF-8",      // mozna kodovani: WINDOWS-1250, ISO-8859-2, UTF-8
    "server_url" => "https://www.domainmaster.cz/masterapi/server.php",
  ));
  

  // spusteni prikazu
  // prvni parametr: nazev prikazu (viz nize v tomto souboru)
  // druhy volitelny parametr: potrebne parametry daneho prikazu
  $result = $client->sendCommand("transfer cz domain",array(
    "transfer" =>    "domena.cz",
    "auth-info" =>   "kfSkrsmc42",
    "idacc" =>       "GR:PLATCE",
    "iddealer" =>    ""
  ));

  // zpracovani vysledku
  if($result->IsSuccess()){
    // uspech
    echo "commnad was successfuly executed\n";
    echo "--------------------------------\n";
    echo "data:\n";
    print_r($result->getData()); // vrati asociativni pole nebo null (podle charakteru odpovedi)
  }else{
    // NEUSPECH!
    // pokud $this->IsTemporaryError() vrati true - jedna se pravdepodobne o docasnou chybu -> nutno pockat 5 minut a pak stejny prikaz odeslat znovu
    echo "commnad WAS NOT executed successfuly\n";
    echo "------------------------------------\n";
    echo "message: ".$result->getMessage()."\n"; // popis chyby
    echo "temporary error: ".($result->IsTemporaryError() ? "yes (request should be repeated)" : "no")."\n";
    echo "------------------------------------\n";
    // pro debug ucely je mozne pouzit nasledujici metody
    // echo "http request:\n";
    // echo $result->getHttpRequest()."\n";
    // echo "http response:\n";
    // echo $result->getHttpResponse()."\n";
  }