<?php
include 'httpsocket.php';
$Socket = new HTTPSocket;
$Socket->connect('yoursite.com',2222);
$Socket->set_login("{admin_username}","{admin_password}");
// {admin_username} and {admin_password} are not specifically your administrative DA user,
// but rather the user that you want to own this new user.
$Socket->query('/CMD_ACCOUNT_USER',
array(
'username' => '', // The User's username. 4-8 characters, alphanumeric
'email' => '', // A valid email address
'passwd' => '', // The User's password. 5+ characters, ascii
'passwd2' => '', // Password double check. 5+ characters, ascii
'domain' => '', // A valid domain name in the form: domain.com
'package' => '', // One of the User packages created by the Reseller
'ip' => '', // One of the ips which is available for user creation. Only free or shared ips are allowed.
'notify' => 'yes', // yes or no. If yes, an email will be sent to email
'action' => 'create',
'add' => 'Submit'
));
$result = $Socket->fetch_parsed_body();
if ( $Socket->get_status_code() != 200 || !empty($result['error']) )
{
// failure.
echo "Failed to add new user: {$result['error']}<br />{$result['text']}";
}
// new user added.
print_r($result);
?>
Program Error
Details: A segmentation fault has occurred
mike_p said:Hi
I'm struggling to create a database using the API.
I can get a list of existing databases for the user's account, I can create POP mail boxes (this proves my socket and login work correctly) BUT every time I try to create a database i get
If I set it up manually with the same name/user/password it works.
If I attempt to create it when one already exists, it tells me it can't because my quota has been reached (i have max 1 db for this account type).
I have tried both /CMD_DB and /CMD_API_POP
Here's the code for my latest attempt:
- <?php
include 'httpsocket.php';
$sock = new HTTPSocket;
$sock->connect('account ip address',2222);
$sock->set_login("bloggs","******");
$sock->set_method('POST');
$mydata = array(
'action' => 'create',
'name' => 'db',
'user' => 'usr',
'passwd' => '******',
'passwd2'=> '******');
$sock->query('/CMD_API_POP',$mydata);
$result = $sock->fetch_body();
echo $result;
?>
Whats going wrong?
mike_p said:<?php
include 'httpsocket.inc';
$sock = new HTTPSocket;
$sock->connect('ipaddress',2222);
$sock->set_login("bloggs","bl0ggs");
$sock->set_method('POST');
$mydata = array(
'action' => 'create',
'domain' => 'bloggs.com',
'name' => 'db',
'user' => 'usr',
'passwd' => 'bl0ggs',
'passwd2'=> 'bl0ggs',
'create' => 'Create'
);
$sock->query('/CMD_DB',$mydata);
$result = $sock->fetch_body();
echo $result;
?>
The onlything Ive changed here is the ip address.
Bloggs.com is a dummy account ive set up for testing.
(DNS is handled by my local hosts file)
They're commented out: when uing the /CMD_DB call they are required. By using the CMD_DB I was able to get the list of existing databases.There is also no mention of "domain" or "create" fields in the API Interface for databases.