cpanel/whm + XMLAPI + error messages - help please!

harshmallow

Registered
Dec 21, 2011
3
0
51
cPanel Access Level
Root Administrator
Hi there.

I'm trying to create subdomains using cpanel api2 functions.

If i try and do something simple like

listaccts(); - this works fine.

If I try and do the subdomain creation, I get this error: (I've removed my exact directory structure from the error code)

<b>Fatal error</b>: Uncaught exception 'Exception' with message 'curl_exec threw error &quot;SSL read: error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac, errno 0&quot; for https://myiphere:2087/xml-api/cpane...allowdot=0&amp;domain=testing&amp;rootdomain=[mydomain]&amp;cpanel_xmlapi_user=root&amp;cpanel_xmlapi_module=SubDomain&amp;cpanel_xmlapi_func=addsubdomain&amp;cpanel_xmlapi_apiversion=2' in /home/[user]/public_html/xmlapi.php:730
Stack trace:
#0 /home/[user]/public_html/xmlapi.php(652): xmlapi-&gt;curl_query('https://91.103....', 'dir=public_html...', 'Authorization: ...')
#1 /home/[user]/public_html/xmlapi.php(875): xmlapi-&gt;xmlapi_query('cpanel', Array)
#2 /home/[user]/public_html/subdrcreate.php(46): xmlapi-&gt;api2_query('root', 'SubDomain', 'addsubdomain', Array)
#3 {main}
thrown in <b>/home/[user]/public_html/xmlapi.php</b> on line <b>730</b><br />


Any ideas how I can get round this? Have I done something wrong?

This is my test script:
PHP:
$auth_user = "root";$auth_pass = "passwordhere";

include("includes/xmlapi.php");
$ip = "myip";

$xmlapi = new xmlapi($ip);//$xmlapi->hash_auth("root",$whmhash);$xmlapi->password_auth($auth_user, $auth_pass);
$xmlapi->set_output('xml');$xmlapi->return_xml(1);$xmlapi->set_debug(1);
$domain = "testing";$rootdomain = 'rootdomain'; $usecanonicalname = 0; $disallowdot = 0; $dir = 'public_html/iwantittopointhere/';$cpuser="root";
$arraySubDomain2 = array(  'dir'          => $dir, 'disallowdot'  => $disallowdot, 'domain'       => $domain, 'rootdomain'   => $rootdomain );  
//print $xmlapi->listaccts();print $xmlapi->api2_query($cpuser, "SubDomain", "addsubdomain", $arraySubDomain2);
Any help would be greatly appreciated. I've never used these APIs before, so I'm learning as I go...

Many thanks!
tasha
 

harshmallow

Registered
Dec 21, 2011
3
0
51
cPanel Access Level
Root Administrator
Update: after spending a whole day trying to get this to work and finally giving in and posting for help, I just tried giving the user for the domain root priveleges and now it seems to work. Whether this was the right way round or not, I don't know, but it works.
 

harshmallow

Registered
Dec 21, 2011
3
0
51
cPanel Access Level
Root Administrator
I do have another question however. My addsubdomain script redirects appropriately after creating the new subdomain.

However, the script with delsubdomain stops immediately after it has deleted the subdomain. There's more script to run after and addsubdomain is called again further down the page but it never gets there.

Has anyone encountered this sort of issue before?

Thanks in advance :)