• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

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