Create reseller user using php API

fuqet

New member
Joined
Nov 13, 2016
Messages
4
Hello.

I can not create reseller user using a pre-made package.. I tried to use code PHP to create normal user and it works, but when I use my admin login and password and $sock->query('/CMD_ACCOUNT_RESELLER' it not working.. What i am doing wrong? Thank for help.
 
Thank you for quick reply.

I use code below

PHP:
<?php
require 'httpsocket.php';

$server_ip="myserverip"; //IP that User is assigned to
$server_login="admin";
$server_pass="mypassword";
$server_host="127.0.0.1"; //where the API connects to
$server_ssl="Y";
$server_port=2222;
 
 
    $username='newreseller';
    $domain='domain.com';
    $email='[email protected]';
    $pass='password';
    $package='rsmall'; // package is created in admin panel
 
    echo "Creating user $username on $server_ip.... <br>\n";
 
    $sock = new HTTPSocket;
    if ($server_ssl == 'Y')
    {
        $sock->connect("ssl://".$server_host, $server_port);
    }
    else
    { 
        $sock->connect($server_host, $server_port);
    }
 
    $sock->set_login($server_login,$server_pass);
 
    $sock->query('/CMD_ACCOUNT_RESELLER',
        array(
            'action' => 'create',
            'add' => 'Submit',
            'username' => $username,
            'email' => $email,
            'passwd' => $pass,
            'passwd2' => $pass,
            'domain' => $domain,
            'package' => $package,
            'ip' => $server_ip,
            'notify' => 'yes'
        ));
 
    $result = $sock->fetch_parsed_body();
 
    if ($result['error'] != "0")
    {
        echo "<b>Error Creating user $username on server $server_ip:<br>\n";
        echo $result['text']."<br>\n";
        echo $result['details']."<br></b>\n";
    }
    else
    {
        echo "User $username created on server $server_ip<br>\n";
    }
 
    exit(0);

echo "Will connect to: ".($server_ssl == "Y" ? "https" : "http")."://".$server_host.":".$server_port."<br>\n";
 
?>

I am using the same code to create user account with reseller login details and it is working, but when I change login details to admin and $sock->query to CMD_ACCOUNT_RESELLER it doesn't work.

Thank you for help.
 
Hello,

problem is solved..

I had to change 'ip' => 'ipaddress',

to

'ip' => 'shared',

:)
 
Back
Top