PHP

You should include a set of PHP classes to invoke methods of Integration API in your application. To do it, click the PHP classes link, copy the PHP code and paste it into the code of the application.

PHP classes

Note: The classes should be declared before invoking Integration API methods.

For details on the set of classes, refer to the PHP Classes Details section.

To create a Plesk Sitebuilder site, the following steps should be taken:

1.   Specify preferences common for all Plesk Sitebuilder web services.

The preferences are as follows:

 

$serviceUrl = 'http://example.com/ServiceFacade/4.1/';
$serviceLogin = 'serviceLogin';
$servicePassword = 'servicePassword';

 

2.   Create an instance of the SOAP client that invokes methods of web service SiteWebService.

$siteService = new Utils_SoapClient($serviceUrl.'/SiteWebService.asmx?WSDL', array());
$siteService->setCredentialsHeader($serviceLogin, $servicePassword);

 

3.   Create an instance of standard PHP class stdClass and specify the site properties. The properties differ depending on a method that will be used for site creation. For details on the methods, refer to the Creating Site section.

A sample of the properties can look as follows:

$struct = new stdClass();
$struct->ownerId = 11;
$struct->siteType = 'Regular';
$struct->siteAlias = 'siteName';
$struct->hostId = 124;
$struct->publishingSettings = new stdClass();
$struct->publishingSettings->Scenario = 'Standard';
$struct->publishingSettings->Mode = 'Ftp';
$struct->publishingSettings->StandardLocation = new stdClass();
$struct->publishingSettings->StandardLocation->UserName = 'myUserName';
$struct->publishingSettings->StandardLocation->Password = 'publishFtpPassword';
$struct->publishingSettings->StandardLocation->WorkingDirectory = '/www/';
$struct->publishingSettings->StandardLocation->WebSiteUrl = 'http://example.com';
$struct->publishingSettings->StandardLocation->Address = 'ftp://example.com';
$struct->publishingSettings->StandardLocation->Veid = 0;

 

4.   Invoke one of the methods used for creating sites. For details on the methods, refer to the Creating Site section. The following example illustrates the use of method CreateSite2.

 

$result = $siteService->CreateSite2(new SoapVar($struct, SOAP_ENC_OBJECT));

 

After the user account is created, you can retrieve preferences of the site. For instance, you can retrieve the ID of the site. The PHP code of the operation looks as follows:

$siteId = $result->CreateSite2Result->Id;

For full PHP code sample, click on the following link: code sample.