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

Perl API::Plesk

B

billguy

Guest
If http://download1.swsoft.com/Plesk/Plesk8.1/Doc/plesk-8.1-api-rpc-guide/33181.htm seems like too much of a hassle (it did for me), have a look at Odintsov Pavel's API::plesk over on CPAN. Neat and tidy.

Example:

use API::plesk;
use API::plesk::Response;

my $plesk_client = API::plesk->new('api_version'=>'1.5.0.0','username'=>'user','password'=>'pass','url'=>'https://example.com:8443/enterprise/control/agent.php');
my $res = $plesk_client->Accounts->get('login' => 'some_user');

print "User exists \n" if $res->is_success;
print $res->get_error_string, "\n";

The documentation could be friendlier but the software is free. ;)
 
More API::plesk examples

Create a Plesk user account.

Code:
	use API::Plesk;
	use API::Plesk::Response;

	#Creates a Plesk user account.
	#Usage: perl plesk_create_user.pl username password full_name email plesk_client_template_name

	#Set Plesk connect credentials here.
	my ($plesk_ver, $plesk_user, $plesk_pass, $plesk_url) = qw(1.5.0.0 admin password https://host.com:8443/enterprise/control/agent.php);

	#Plesk vars.
	my ($user, $pass, $name, $email, $client_template) = ($ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4]);

	#Build user data hash ref.
	my $user_data = {
		#'cname'   => , # company name 
		'pname'   => $name,
		'login'   => $user,
		'passwd'  => $pass,
		'status'  => '0',   
		#'phone'   => ,
		#'fax'     => ,
		'email'   => $email,
		#'address' => ,
		#'city'    => ,
		#'state'   => , 
		#'pcode'   => , 
		#'country' => , 
	};

	#Connect to Plesk.
	my $plesk_client = API::Plesk->new('api_version'=>$plesk_ver,'username'=>$plesk_user,'password'=>$plesk_pass,'url'=>$plesk_url);

	#Create the user account. Make sure you have a plesk template already created.  Use a Plesk client template name.
	my $plesk_usercreate_res= $plesk_client->Accounts->create('general_info'=>$user_data, 'template-name'=>$client_template);

	#Print the result.
	$plesk_usercreate_res->is_success ? print "$user created. \n" : print $plesk_usercreate_res->get_error_string, " \n";

Create a Plesk domain.

Code:
	use API::Plesk;
	use API::Plesk::Response;

	#Creates a Plesk domain.
	#Usage: perl plesk_create_domain.pl domain_name plesk_owner_username ftp_user ftp_pass ip_address plesk_domain_template_name 

	#Set Plesk connect credentials here.
	my ($plesk_ver, $plesk_user, $plesk_pass, $plesk_url) = qw(1.5.0.0 admin password https://host.com:8443/enterprise/control/agent.php);

	#Plesk vars.
	my ($domain, $username, $ftp_user, $ftp_pass, $ip, $dom_template) = ($ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5]);

	#Connect to Plesk.
	my $plesk_client = API::Plesk->new('api_version'=>$plesk_ver,'username'=>$plesk_user,'password'=>$plesk_pass,'url'=>$plesk_url);

	#Fetch the userid from the username.  Exit if not exist.
	my $plesk_res= $plesk_client->Accounts->get('login' => $username);
	$plesk_res->is_success ? my $userid = $plesk_res->get_data->[0]{'id'} : print $plesk_res->get_error_string, " \n";

	#create the domain, make sure you have a good plesk template already created.  Use a Plesk template name.
	my $plesk_domaincreate_res= $plesk_client->Domains->create('dname'=>$domain, 
									    'ip'=>$ip, 
									    'client_id'=>$userid,
									    'ftp_login'=>$ftp_user,
									    'ftp_password'=>$ftp_pass,
									    'template'=>$dom_template);

	#Print the result.
	$plesk_domaincreate_res->is_success ? print "$domain created. \n" : print $plesk_domaincreate_res->get_error_string, " \n";

Enjoy!
 
What I did was built a .Net wrapper available in a web service that sits in a load balanced web server to use as a centralized web service going to all plesk hosting boxes to do these types of things :)

Very smiilar, but unreleased to the public unfortunately
 
Thanks billguy!

Would it be possible when a user login Plesk and use API::plesk to automatically view/get the databases and create one?
 
Can you please tell how to add a subdomain to an existing domain?
http://search.cpan.org/~nrg/API-Plesk-1.09...omainAliases.pm

try:
Code:
#!/usr/bin/perl



use API::Plesk;


#use API::Plesk::Response;

use API::Plesk::DomainAliases;

use Data::Dumper;


my ($plesk_ver, $plesk_user, $plesk_pass, $plesk_url) = qw(1.5.0.0 user pass https://s.s.com/login_up.php3);


my ($domain, $username, $ftp_user, $ftp_pass, $ip, $dom_template) = ($ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3], $ARGV[4], $ARGV[5]);


my $plesk_client = API::Plesk->new('api_version'=>$plesk_ver,'username'=>$plesk_user,'password'=>$plesk_pass,'url'=>$plesk_url,'debug'=>'1','request_debug'=>'1' );

#print Dumper $plesk_client;

 my $res = $plesk_client->DomainAliases->create(
    domain_name  => 'v.com',
 );

#    my $res = $plesk_client->Func_Module->operation_type(%params);

 print Dumper $res;


#   print $res->is_success;
    
   # my $a = $res->get_data; # return arr ref of answer blocks
   
#   print $a;
    

$res->is_success ? my $userid = $res->get_data->[0]{'id'} : print $res->get_error_string, " \n";

print $userid;


I return:
Code:
plesk_query: blank request

what's wrong?


what is the possibility to add a subdomain of an existing domain?

through the API? (perl,php,etc)
be an example?
 
Back
Top