• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

[API Plesk] How to add a subdomain (alias domen)?

G

gcc4

Guest
HI!

I found:
http://forum.parallels.com/pda/index.php/t-81079.html


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?
 
Do you mean Parallels Small Business Panel or Parallels Plesk Panel?
 
Excuse me, please:
'Parallels Plesk Panel' hosting

(...there is a accaunt someone wrote...)
 
Code:
.........
<domain_id>1</domain_id>
.........

I have a domain, but I do not know what his ID, how do you know what ID from a specific domain?
 
You can find domain ID if you put mouse pointer over domain name and you will see ID in browser's status bar.
 
I brought a mouse in firefox3
was there ID .....

but as you can see more?
 
Look at browser status bar. You will see dimain@8 or domain@17 there. It is domain ID (8,17).
 
Code:
<?php

$host="s.com";
$login="name";
$passwd="111111";
$port=8443;

$data = <<<EOF
<packet version="1.4.2.0">
<mail>
<create>
<filter>
<domain_id>308</domain_id>
<mailname>
<name>test2.domain.com</name>
<cp_access>
<enabled>true</enabled>
</cp_access>
</mailname>
</filter>
</create>
</mail>
</packet>
EOF;

function write_callback($ch, $data) {
echo $data;
return strlen($data);
}

function sendCommand($data, $login, $passwd, $host, $port=8443) {
$script = "login.php";
$url = "https://$host:$port/$script";
$headers = array(
"HTTP_AUTH_OP: $operator",
"HTTP_AUTH_LOGIN: $login",
"HTTP_AUTH_PASSWD: $passwd",
"HTTP_PRETTY_PRINT: TRUE",
"Content-Type: text/xml",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, &$headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, write_callback);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$result = curl_exec($ch);
if (!$result) {
echo "\n\n-------------------------\ncURL error number:".curl_errno($ch);
echo "\n\ncURL error:".curl_error($ch);
}
curl_close($ch);
return;
}
sendCommand($data, $login, $pass, $host, $port);

?>


Warning: Call-time pass-by-reference has been deprecated in /home/autoprofi.ua/plesk.php on line 44

loading.gifPlease wait.
Loading ...
Log in to Parallels
Plesk Control Panel 8.6

Enter the login name into "Login" and password into the "Password" fields respectively. Then click "Login".


my username and password 100% correct

why not work?
 
show you you have it working? what could be the problem?

Can there be a problem with different versions of the API plesk??

developers test your API? why not write more examples?

(Although I'll try to still be my problem)
 
show you how to work through the API? what to do with this error?
 
I'm trying to create a subdomain using C# in Parallels Plesk Panel 11.
Which username and Password should i enter for the requests I'm sending?!
What ever username and password I enter I receive " You have entered incorrect username or password. " error...
Can I interact with the panel as a normal user? or do I need a special authority from the administrators?
My current access level to the panel is OWNER
 

Similar threads

Back
Top