Issue with using the createacct($acct) function for creating domains


Jan 29, 2013
cPanel Access Level
Website Owner
Hello folks,
I am working on an application that allows users to log in and create their own domains by selecting a relevant domain name.I went through the docs and studied the use of cpanel API class and functions.I worked with the createacct($acct) function and got it working,but I have some issues with its working.
1) When I try to create a domain with some name,the API fails to create one,but instead if I try the same using WHM panel it creates a domain with that name.For eg: I tried using a name nageshtest,I was not able to create it and if I try the same with WHM it worked.What must the issue with it or am I doing something silly?I believe only if the domain is already present it should be disallowed(ofcourse I am taking care of not entering special characters).So,what can be the issue?
2) When I create a account I get a long message saying Your account has been created successfully and when it fails it returns the details with the error message.How could I get a true or false based message or only the error code or text,so that I can display it to the user ?

Adding my code for reference:


 $acct = array( 'username' => $userName, 'password' => $password, 'domain' => $domain);

 $createAccount= $xmlapi->createacct($acct);
 if(strpos($createAccount,'Account Information')===false)
	    echo "Your domain has not been created";
		echo $createAccount;		
		echo "Your domain has been created successfully";
The variable createAccount returns a long text,but I need something like true false or an error code.
I believe I am clear enough to get some help!

Thank you
Last edited: