By default, the API calls are performed under the privileges of the
current user. However, sometimes the actions require the administrative
privileges. In such cases, the $login
argument of the call()
method should be used.
For example, let’s look at an extension that turns on PHP settings for a
subscription. The extension sends the following request:
$request = <<<APICALL
<webspace>
<set>
<filter>
<id>2</id>
</filter>
<values>
<php-settings>
<setting>
<name>extension</name>
<value>msql.so</value>
</setting>
</php-settings>
</values>
</set>
</webspace>
APICALL;
To perform this request, you need administrator’s rights:
$response = pm_ApiRpc::getService()->call($request, 'admin');
Error Handling
If you run an XML API call with data which is not a valid XML tree, a
PHP warning will be generated.
If an XML packet is not a valid operation call, the system will throw
the PleskAPIParseException
exception.