Skip to main content

xmlapi addsubdomain gives error in cpanel.pl line 1825

Comments

3 comments

  • cPanelMichael
    Hello, Here's a closer example, using JSON instead of XML, that you may find helpful: JSON-API calls to make new subdomain, email, ftp, and database help Thank you.
    0
  • nickwuk
    @cPanelMichael thanks for the link. To start with I couldn't see much difference in the code since the variable $json_client was the same as my $xmlapi ie an both instance of class xmlapi. Looking closer I found that I needed to change the module title from 'Subdomain' to 'SubDomain' with an uppercase 'D', use function api2_query instead of api1_query, and restructure my $opts array to include keys and then it worked. [PHP]include 'xmlapi.php'; $cpanel_host = 'mydomain.uk'; $cpanel_user = 'someuser'; $subdomain = 'mysubdomain'; $cpanel_pass = 'mypass'; $dir = 'public_html/'.$subdomain; $xmlapi = new xmlapi($cpanel_host); $xmlapi->password_auth($cpanel_user, $cpanel_pass); $xmlapi->set_http_client('curl'); $xmlapi->set_port(2083); $xmlapi->set_output('json'); $xmlapi->set_debug(1); $opts = array('domain' => $subdomain, 'rootdomain'=> $cpanel_host, 'dir' => $dir, 'disallowdot'=> '1'); print $xmlapi->api2_query($cpanel_user, "SubDomain", "addsubdomain", $opts);[/PHP]
    0
  • cPanelMichael
    Hello, I'm glad to see you were able to get it working. Thank you for updating us with the outcome.
    0

Please sign in to leave a comment.