Příklad z běžné praxe
Prohlížení domény (příkaz show domain) je jedna z velmi častých úloh, které je nutné v praxi provádět.
JSON
HTTP požadavek...
POST /masterapi/server.php HTTP/1.0
Host: www.domainmaster.cz
Content-Type: text/plain; charset=UTF-8
Content-Length: 63
Authorization: Basic R1I6VE9NRUs6dG90b19hc2lfbmVuaV9oZXNsbw==
{"command":"show domain","params":{"domain":"domainmaster.cz"}}
... a odpověď:
HTTP/1.0 200 OK
Date: Tue, 24 Sep 2013 14:41:02 GMT
Server: Apache
Content-Length: 302
Connection: close
Content-Type: text/json; charset=UTF-8
{
"status": "success",
"message": "Ok",
"data": {
"domain": "domainmaster.cz",
"registrant": "STEFANOC",
"nsset": "GRDNS",
"admin": [],
"tempcontact": [],
"registrar": "REG-GENREG",
"create_date": "2003-08-25",
"expiry_date": "2014-08-24",
"idacc": "PA:GR",
"iddealer": "PA:GR",
"status": {
"ok": "Objekt is without restrictions"
}
}
}
YAML
HTTP požadavek...
POST /masterapi/server.php HTTP/1.0
Host: www.domainmaster.cz
Content-Type: text/plain; charset=UTF-8
Content-Length: 60
Authorization: Basic R1I6VE9NRUs6dG90b19hc2lfbmVuaV9oZXNsbw==
---
command: show domain
params:
domain: domainmaster.cz
... a odpověď:
http response:
HTTP/1.0 200 OK
Date: Tue, 24 Sep 2013 14:42:06 GMT
Server: Apache
Content-Length: 294
Connection: close
Content-Type: text/plain; charset=UTF-8
---
status: success
message: Ok
data:
domain: domainmaster.cz
registrant: STEFANOC
nsset: GRDNS
admin: []
tempcontact: []
registrar: REG-GENREG
create_date: 2003-08-25
expiry_date: 2014-08-24
idacc: PA:GR
iddealer: PA:GR
status:
ok: Objekt is without restrictions
PHP klient
<?php
$result = $client->sendCommand("show domain",array("domain" => "domainmaster.cz"));
$result->isSuccess(); // true
echo $result->getMessage(); // "Ok"
print_r($result->getData()); // array("domain" => "domainmaster.cz", "registrant" => "STEFANOC", ... )