ajtaylordev
New Pleskian
Hello, so I am in the process of creating a hosting website. I'm fairly new to using APIs but I have managed to successfully connect and create a user using PHP/curl.
I'll just show my code as its probably a better way to show you where I am up to:
Now I want them to be able to only have the service plan that they have paid for. I have tried a few things, this is the closest I've got using cli method:
Can anybody help me?
Thanks.
I'll just show my code as its probably a better way to show you where I am up to:
So that above bit works fine, I can create a customer and they appear in my Plesk admin panel.// CREATE NEW CUSTOMER //
$url = 'https://example.com/api/v2/clients';
$data = array(
'name' => 'John Smith',
'company' => 'Plesk',
'login' => 'john-unit-test',
'status' => '0',
'email' => 'john_smith@msn.com',
'locale' => 'en-US',
'owner_login' => 'admin',
'external_id' => 'link:12345',
'description' => 'Nice Guy',
'password' => 'changeme1Q**',
'type' => 'customer'
);
$payload = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Accept: application/json';
$headers[] = 'X-API-Key: '.$secret_token.'';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
Now I want them to be able to only have the service plan that they have paid for. I have tried a few things, this is the closest I've got using cli method:
So what that above does is create a new domain, but the subscriber is admin (me) whereas I want it to be the customers username. The subscription for that customer is totally blank. Id like it to be for John Smith "newdomain.com(Bronze_Package)".// ADD SUBSCRIPTION PLAN TO CUSTOMER USING REST API CLI METHOD //
$url = 'https://a530107.online-server.cloud/api/v2/cli/subscription/call';
$payload = "{ \"params\": [\"--create\", \"newdomain.com\", \"-owner\", \"admin\", \"-service-plan\", \"Bronze_Package\", \"-ip\", \"82.XXX.XXX.XXX\", \"-login\", \"john-unit-test\", \"-passwd\", \"changeme1Q**\"]}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'Content-Type: application/json';
$headers[] = 'X-API-Key: '.$secret_token.'';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
Can anybody help me?
Thanks.