Create User On DA

phuongthai

New member
Joined
Nov 11, 2015
Messages
1
I have a script create user on DA
<?php

include 'httpsocket.php';

$sock = new HTTPSocket;

$sock->connect("192.168.1.200", 2222);
$sock->set_login("admin", "123456");

$sock->query('/CMD_API_ACCOUNT_USER', array(
'action' => "create",
'add' => "Submit",
'username' => 'hau',
'email' => "[email protected]",
'passwd' => '123456',
'passwd2' => '123456',
'package' => 'hau',
'ip' => "192.168.1.200",
'notify' => "yes"
));

$result = $sock->fetch_parsed_body();

?>
But I run this script, It don't create user on DA, I expect from everyone, thank many.
 
You forgot to specify the default domain, which is mandatory.

In the new API client your code should be:

Code:
$admin = DirectAdmin::connectAdmin('http://192.168.1.200:2222', 'admin', '123456');
$user = $admin->createUser('hau', '123456', '[email protected]', 'hau.example.org', '192.168.1.200', 'hau');

Relevant documentation here.
 
Last edited:
not working..



Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: cURL error 7: Failed to connect to 2.56.63.3 port 2222: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in /home/akepanel/public_html/directadmin/omines/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:200 Stack trace: #0 /home/akepanel/public_html/directadmin/omines/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(155): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 /home/akepanel/public_html/directadmin/omines/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(105): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 /home/akepanel/public_html/directadmin/omines/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(Guzzle in /home/akepanel/public_html/directadmin/omines/vendor/omines/directadmin/src/DirectAdmin/DirectAdmin.php on line 167


Code:
require "vendor/autoload.php";

use Omines\DirectAdmin\DirectAdmin;


 
$admin = DirectAdmin::connectAdmin('http://2.56.63.3:2222', 'admin', 'f79FxxxLIHh0ki');
$user = $admin->createUser('hau', '123456', '[email protected]', 'example.org', '127.0.0.1', 'full');

I have never been able to work.
 
Back
Top