Help me to create Account via API PHP

fabioliotta

Registered
Feb 23, 2014
3
0
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 => "[email protected]",
domain => "domain.com",
contactemail => "[email protected]",
pkgname => "package_name"
);

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



but nothing happens


Could someone help me please with this?
 

fabioliotta

Registered
Feb 23, 2014
3
0
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'=>'[email protected]'));

//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?