XMLAPI adding parked domain woes!

WebJIVE

Well-Known Member
Sep 30, 2007
124
18
68
XMLAPI adding parked domain woes! help..

I need some help or direction here on how to solve this puzzle. I own a hosting company and I have been wanting to automate some tasks for a while. One of the automation features I wanted was automatic parked domain creation so that users would have a temp/developer URL to use before taking their site live.

We use WHMCS and I have created an action hook for this.

What we're trying to automate:
1. new account name = harryp, new account domain = willworklater.com
(this will resolve after the client changes their DNS once their happy with the new site)

2. live domain that resolves properly = workingdomain.com
(belongs to another account we own, but is a working URL)

If I use the WHM "Park A Domain" feature as root, I can park "harryp.workingdomain.com" on top of "willworklater.com" so the user can develop their site by using "harryp.workingdomain.com".

I'm trying to use the XMLAPI 2 in a PHP script to do this but, I keep getting the error:
The following domain is not configured for this account: willworklater.com (example domain)

The PHP code I have slapped together is:
Code:
<?php //Park a domain for a new account
	function createparkeddomain($vars) {
//			print_r($vars);
			$cpanel_user = $vars['params']['username'];
			$cpanel_password = $vars['params']['password'];
			$cpanel_domain = $vars['params']['domain'];
			$cpanel_ip = $vars['serverip'];
			$pdomain = $cpanel_user.".web-jive.com";

			include_once('xmlapi.php');
			$xmlapi = new xmlapi($cpanel_ip);
			$xmlapi->set_port(2082);
			$xmlapi->password_auth($cpanel_user,$cpanel_password);
			$xmlapi->return_xml(1);
			$xmlapi->set_debug(1);
//			$args = array(domain => $pdomain); 
//			print $xmlapi->api2_query($cpanel_user, 'Park', $args); 
//			print $xmlapi->api2_query($cpanel_user, "Park", "park", array(newdomain=>$pdomain, topdomain=>$cpanel_domain));  
//			print $xmlapi->api2_query($cpanel_user, 'Park', 'park', array( 'domain' => $pdomain, 'topdomain' => $cpanel_domain ) );
  
			print $xmlapi->park($cpanel_user, $pdomain, $cpanel_domain);  

}

add_hook("AfterModuleCreate",1,"createparkeddomain");	

?>
As you can see, we have tried variations of this XMLAPI but, they come back with the same result. Any thoughts on this delima?

We stopped using mod_userdir a long time ago due to he security holes that opens up and, this is our way to easily solve this; to create parked domains.

Thanks!
 
Last edited:

WebJIVE

Well-Known Member
Sep 30, 2007
124
18
68
Wow.. no reply from cPanel?
 

WebJIVE

Well-Known Member
Sep 30, 2007
124
18
68
Ok, MANY thanks to John Kata fom cPanel support who helped me get this working. Couple of things, first you need to set cPanel to allow parking across domains:

WHM -> Tweak Settings -> Domains -> Allow domain parking across accounts

This is the line of code that got it working and John is going to get the API docs updated to reflect this.

Code:
print $xmlapi->api2_query($cpanel_user, 'Park', 'park', array('domain' => $pdomain));
Thanks John Kata!
 

cPanelDavidN

Well-Known Member
Staff member
Dec 17, 2009
571
3
68
Houston, TX
cPanel Access Level
Root Administrator
Hi Eric,

Sorry I couldn't get to your post sooner. This doesn't address your exact problem, but...John got a hold of me and pointed out that there was a discrepancy in the xmlapi client class vs. the documentation vs. the behavior of API2 Park::park. The convenience method "park()" in the xmlapi PHP client class has been updated to reflect this. The xmlapi PHP client class is now version 1.0.11.

Regards,
-DavidN

PS. The documentation for API2 Park::park should be updated shortly with more description concerning the 'topdomain' argument.
 

WebJIVE

Well-Known Member
Sep 30, 2007
124
18
68
No worries. We got it figured out. I wanted to avoid using the unsecure temp URL method of mod_userdir for new sites and use parked domains. Once we set a setting in cPanel and corrected the API call, all is good. :)

Now that I have that behind me, we can move on to more XMLAPI duties. Thanks for the PHP API library! Makes life a lot easier.
 

cPanelDavidN

Well-Known Member
Staff member
Dec 17, 2009
571
3
68
Houston, TX
cPanel Access Level
Root Administrator
Glad that we could help!

Another note to ALL:
Opening a support ticket is a great way to get things resolved quickly, and it's a complimentary service available to all cPanel users. If it's a technical issue (that's been posted in the forum) that isn't getting the traction feel free to PM me and I will try to respond in a timely manner. [please keep in mind, we have holiday too!]

Best Regards to ALL,
-DavidN