Search code examples
web-hostingcpanel-xmlapi

how to host customers domain on my server using cpanel api


i am searching a lot here

https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+2

https://documentation.cpanel.net/display/SDK/Guide+to+cPanel+API+1

but didn't found any correct way. what my requirement is i need to host a domain on my server programmatically, where my clients provide me its domain name (ex: test.com) via a form and when he submit that form, i will set a wordpress site for it using that domain. Currently i setup a subdomain programmatically using cpanel api, what my requirement here is hosting a domain on my server and i have to do this using api.


Solution

  • Above I have suggested the way to create addon domain on a cpanel. Hereunder is the code to generate new cpanel account on WHM or server

    $xmlapi = new \xmlapi($reseller->url);
    //checking authentication of the cpanel
    $xmlapi->password_auth($reseller->username, $reseller->password);                                                   
    $xmlapi->set_port(2087);
    $xmlapi->set_output('json');
    
    $conf = array("username"=>$username,"password"=>$password,"domain"=>$domain,"pkgname"=>$package,"contactemail"=>$contactemail,"cpmod"=>"x3");
    
    $result = json_decode($xmlapi->createacct($conf));