• 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!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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