• 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.

Question access thorugh url gives error

hamza-24

Basic Pleskian
Server operating system version
centOS 7
Plesk version and microupdate number
18.0.50
i am using the folowing code for creating user using rest API
<?php
// Define Plesk API credentials
$host = 'abc.xyz.123';
$login = 'admin';
$password = '@{dQr-r3$MCiWlZ';
// Define customer details
$customerName = 'testcustomer';
$customerEmail = '[email protected]';
$customerUsername = 'customer';
$customerPassword = 'temp1234@';
// Build API request body
$requestBody = <<<EOT
<customer>
<gen_info>
<pname>{$customerName}</pname>
<email>{$customerEmail}</email>
<username>{$customerUsername}</username>
<password>{$customerPassword}</password>
</gen_info>
</customer>
EOT;
// Send API request to create customer
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://{$host}:8443/api/v2/customers");
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/xml',
'Authorization: Basic ' . base64_encode("{$login}:{$password}")
));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
// Parse API response
$xml = simplexml_load_string($response);
if ($xml->xpath('//errtext')) {
echo "Error creating customer: {$xml->errtext}\n";
} else {
$customerId = $xml->id;
echo "Customer created with ID {$customerId}\n";
}
?>
but it gives me error page not found and no user is created
 
@hamza-24, just like any other web page you'll have to upload your test.php page to the webspace of a domain where you can access it via example.com/test.php.

It looks like you're new to PHP, maybe these free PHP courses will help you beter understand how to work with PHP.
 
sorry for my lack of knowledge but I just want to understand how I can connect the API so that user creation is automated when someone signups.
really confuse din that. @Kaspar
 
Your script is connecting to API via curl - it looks OK besides the xml/json part. Now you have to place your script somewhere so it can be called.
Talking in Plesk terms, you would create a domain with PHP enabled and upload it via File manager.

So the basic setup looks like this:
1. You have an API endpoints, provided by Plesk at https://<Plesk URL or IP>:8443/api/v2/<endpoint-name>
2. You have your domain https://some-domain.com created in Plesk
3. You upload a .php file (e.g. form.php) via File manager
4. You open https://some-domain.com/form.php in your browser and can see the results of your script execution
 
Back
Top