EHCP API Help needed
Hello
I want to make use of the EHCP API, however im having some trouble with it.
Im trying to use one of the default api examples, namely api2.php:
Heres the code it has:
require("../classapp.php");
$domainname = "d2omainsite.com";
$panelusername = "blabla";
$ftppassword=$paneluserpass="123";
$ftpusername = "ftpusername2";
$status="active";
$app = new Application();
$app->connectTodb(); # fill config.php with db user/pass for things to work..
$app->activeuser=$panelusername;
$ret=$app->addDomainDirect($domainname,$panelusername,$paneluserpass,$ftpusername,$ftppassword,$status,$email='',$quota=0);
if($ret){
echo "Success";
} else {
echo $app->output;
}
echo "($ret)";
My problem is that the above code returns and error that the user "blabla" is not active:
Error:User is not active..: blabla (Your account not active,contact your panel service provider, status: )
If you just upgraded your ehcp, try to logout, login back.
It is true that the user is not active, but am i completely missing something, when my thought was the script was supposed to create the user? Or do i use it wrong?
Oh and config.php is holding the correct db information..
ehcpdeveloper
Wed, 09/24/2014 - 15:04
Permalink
the command "addDomainDirect"
the command "addDomainDirect" in that api, "adds/setups domain in an 'existing paneluser'".
So, you should add/setup the user before adding domain, in similar way:
$app->activeuser="admin"
$app->addPanelUserDirect($panelusername,$paneluserpass,1,0,0,0,0,10000,'',$email,"active");
$ret=$app->addDomainDirect($domainname,$panelusername,$paneluserpass,$ftpusername,$ftppassword,$status,$email='',$quota=0);
if($ret){
echo "Success";
} else {
echo $app->output;
}
The panelusername parameter in addDomainDirect is used to set the "owner" of new domain, not for adding paneluser.
But, I accept your case like a "feature request" and will add an all-in-one command next time.
Thank you for you inspiration.
djda9l
Tue, 09/30/2014 - 12:42
Permalink
Now getting new error
Thanks for your assistance!
I tried you code, but then i get another error, actually the direct opposite as before : "panelusername already exists: blabla"
It should be mentioned that i have already tried with an existing user, before you wrote the first time, which gave me the same error.
Heres my code for reference, i believe it should be working as per what you wrote earlier:
require("../classapp.php");
$domainname = "d2omainsite.com";
$panelusername = "blabla";
$ftppassword=$paneluserpass="123";
$ftpusername = "ftpusername2";
$status="active";
$email="";
$app = new Application();
$app->connectTodb(); # fill config.php with db user/pass for things to work..
$app->activeuser="admin";
$app->addPanelUserDirect($panelusername,$paneluserpass,1,0,0,0,0,10000,'',$email,$status);
$ret=$app->addDomainDirect($domainname,$panelusername,$paneluserpass,$ftpusername,$ftppassword,$status,$email='',$quota=0);
if($ret){
echo "Success";
} else {
echo $app->output;
}
echo "($ret)";
djda9l
Tue, 09/30/2014 - 16:40
Permalink
Oh and as for the above i
Oh and as for the above i have checked that the user do not exist when the script is run. I can also see that the script has success on creating the user, but that the addDomainDirect function fails to use it for some reason with the above message
ehcpdeveloper
Wed, 10/01/2014 - 11:00
Permalink
I will check this and fix if
I will check this and fix if anything wrong.
djda9l
Wed, 10/01/2014 - 16:25
Permalink
Thanks again
If you do not find any bugs, please let me know so i can look further into my own code