Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Create subdomains using php?! And a few other stuff

Discussion in 'cPanel Developers' started by alexsimi80, Aug 23, 2010.

  1. alexsimi80

    alexsimi80 Registered

    Aug 23, 2010
    Likes Received:
    Trophy Points:

    I am a newbie in cPanel's API so I really need help to do something. So, I have to make 3 things when someone creates an account to my website:
    1. Create a subdomain like
    2. Create an e-mail address for the subdomain -
    3. Create a database.

    I have to make all this in a php script, so I think I must use API but I tryed to learn something about it and it is to hard for me for the moment.
    So, could someone just give me some examples of how to do any/all of those 3 actions?

  2. alexsimi80

    alexsimi80 Registered

    Aug 23, 2010
    Likes Received:
    Trophy Points:
    I found a sollutin but it's not working.
    The code is this:
    $login = "user";
    $pass = "pass";
    $domain = "";
    $output = fopen ("http://$login:$pass@www.$domain:2082/frontend/x3/subdomain/doadddomain.html?domain=$subdomain&rootdomain=$domain&go=Create", "r");
    print ("Subdomain Created.<br>\n");
    The code works but with no effect :(. If I try to paste the link "http://$login:$pass@www.$domain:2082/frontend/x3/subdomain/doadddomain.html?domain=$subdomain&rootdomain=$domain&go=Create" in the browser, it creates a subdomain, but if I run that script it doesn't.
    What am I doing wrong?

    Later edit: If I try to print $output, the result is: Resource id #3
    #2 alexsimi80, Aug 23, 2010
    Last edited: Aug 23, 2010
  3. cPanelDavidN

    cPanelDavidN Integration Developer

    Dec 17, 2009
    Likes Received:
    Trophy Points:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Hi Laurentiu,

    You should take a look at the XMLAPI PHP client class. It's let's you programmatically code PHP to perform WHM/cPanel tasks against the XMLAPI interface. There are native XMLAPI functions, used for tasks normally performed in WHM, and you can make cPanel API requests too (like the ones you mentioned).

    You can download it here,
    The tarball has some examples. You should search around the forums, there's lots of examples of how to use it proficiently. Also, there's the Integration Blog which has some posts that use it too.

    Let me know if you have any specific questions.
    Best Regards,
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice