• Debian 11 is approaching its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.80 will be the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

Resolved retrieve site-id using the PHP API (/plesk/api-php-lib)

Beat Stieger

New Pleskian
How can i properly get a site-id using the PHP library offered by Plesk?

I only get the following Object informations using $client->Site()->get('name','domain-a-a.ch'):
PleskX\Api\Struct\Site\GeneralInfo Object
(
[name] => domain-b-b.ch
[asciiName] => domain-b-b.ch
[guid] => 66668abc-1234-1234-abc4-1234a1ab1234
[status] => 0
[description] =>
)

If i interpret well the XML response documented under Getting Information About Sites, there should be returned an <id> as well...
 
Hello,
Retrieving site id is not supported at the moment. However, this is an open source project and you can help us by contributing to plesk/api-php-lib
 
If anyone else runs into this problem: You can use the "request" method of your API client instance to get an object representation of the raw data. You will have to construct the XML Request yourself, but you get all the data that is otherwise unaccessible.

//Code exmaple:

function get_site_data($domain) {
//get client instance
$client = new \PleskX\Api\Client($server_ip);
$client->setCredentials($api_user, $api_pw);

//construct request
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><packet></packet>', null, false);
$site = $xml->addChild('site');
$get = $site->addChild('get');
$filter = $get->addChild('filter');
$filter->addChild('name', $domain);
$dataset = $get->addChild('dataset');
$dataset->addChild('gen_info'); //optional meta data

//return result
return $client->request($xml);
}

//Output object structure:

object(PleskX\Api\XmlResponse) (4) {
["status"]=> string(2) "ok"
["filter-id"]=> string(11) "example.com"
["id"]=> string(1) "1" // ----> that's what you are searching for
["data"]=> object(PleskX\Api\XmlResponse) (1) {
// ---various other meta data, based on "/filter/dataset" node---
}
}
 
Back
Top