Plesk

XML API – Example 1: Getting information on a subscription (XML API protocol specified)

To perform an operation of getting information on a subscription via XML
API with a specified protocol version, use the code:

$request = <<<APICALL
<webspace>
  <get>
    <filter>
      <id>170</id>
    </filter>
    <dataset>
      <gen_info/>
    </dataset>
  </get>
</webspace>
APICALL;
$response = pm_ApiRpc::getService('1.6.3.3')->call($request);
echo 'Domain name: ' . $response->webspace->get->result->data->gen_info->name;

 The PHP library allows to achieve the same goal using this code:

$client = new PleskXApiexternalClient();
echo 'Domain name: ' . $client->webspace()->get('id', 170)->name;

The following sample project is provided by Plesk to illustrate the use
of XML API PHP library: https://github.com/plesk/ext-php-api-lib-demo.

Exit mobile version