The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help me to create Account via API PHP

Discussion in 'cPanel Developers' started by fabioliotta, Feb 23, 2014.

  1. fabioliotta

    fabioliotta Registered

    Joined:
    Feb 23, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Hello,

    i just want to create account on WHM via API PHP,

    i've just found something surfing here but no one has working properly.

    basically i try to do this:

    include_once 'xmlapi-php-master/xmlapi.php';

    ----------
    $ip = getenv('PUT_HERE_IP');
    $root_pass = getenv('PUT_HERE_PASSWORD_OF_WHM');

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth("root",$root_pass);
    $xmlapi->set_output("xml");
    $xmlapi->set_debug(1);


    $acct = array(
    username => "some_username",
    password => "some_p@ssw0rd",
    domain => "domain.com",
    contactemail => "hosting@domain.com",
    pkgname => "package_name"
    );

    print $xmlapi->createacct($acct);
    ------------



    but nothing happens


    Could someone help me please with this?
     
  2. fabioliotta

    fabioliotta Registered

    Joined:
    Feb 23, 2014
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    cPanel Access Level:
    Root Administrator
    Problem creating DB via API PHP

    Hello,

    i got error mesage creating a db via API PHP

    here is the code



    include 'xmlapi-php-master/xmlapi.php';

    $ip = 'IP_ADDRESS'; #IP of your cPanel/WHM server
    $user = 'cpanel_username'; #cpanel username
    $pass = 'password_hosting'; #password of your cPanel user

    $xmlapi = new xmlapi($ip);
    $xmlapi->password_auth($user,$pass);
    $xmlapi->set_port(2083);
    $xmlapi->set_output("xml");
    $xmlapi->set_debug(1);


    $dominio='domain.com';


    print $xmlapi->api1_query($user, "Mysql", "adddb", 'db_name');

    //create user
    print $xmlapi->api1_query($user, "Mysql", "adduser", array(
    'user' => 'db_user',
    'pass'=>'some_p@assw0rd'));

    //add user to database
    $xmlapi->api1_query($user, "Mysql", "adduserdb", array(
    'user'=>'cpanel_username_db_user',
    'db' => 'cpanel_username_db_name',
    'SELECT INSERT UPDATE CREATE DELETE ALTER DROP'));

    i've got this error message

    "..Mysqladdusereventinternal1 1 No username given..."

    could someone please help me with this?
     
Loading...

Share This Page