MyChat Integration API: MCIAPI_CS_RegisterNewUser, register a new user

MyChat Integration API: MCIAPI_CS_RegisterNewUser, register a new user

Register a new user on the server.

 

Syntax

{

 "cmd"        : "0010",

 "ServerKey"  : "iddqd",

 "APIStype"   : "mydata",

 

 "Nick"       : "JohnSmith",

 "Password"   : "mysecretword",

 "Email"      : "john@fbi.com",

 "Domain"     : "circle1.fbi.com",

 

 "FirstName"  : "John",

 "LastName"   : "Smith",

 "MiddleName" : "M.",

 "Sex"        : 1,

 "IP"         : "192.168.10.137",

 "NetName"    : "comp01",

 "ClientType" : "web",

 "AuthType"   : 0

}

 

Parameters

Parameter

Type

Value

ServerKey

string

IntegrationAPI key, can be set in the server settings;

APIStype

string

integration type. You can set any string;

Nick

string

user nickname, this field is necessary and unique;

Password

string

user's password. This field can be empty if a paswordless authorization is used;

Email

string

user's email address. Unnecessary parameter;

Domain

string

user's domain name. Unnecessary parameter;

FirstName

string

user's name. Unnecessary parameter;

LastName

string

user's last name. Unnecessary parameter;

MiddleName

string

user's middle name. Unnecessary parameter;

Sex

integer

user's gender. Unnecessary parameter. It set as "unspecified" by dfefault;

IP

string

user's IP address. Unnecessary parameter;

NetName

string

computer network name of a user. Unnecessary parameter;

ClientType

string

client application type. One of the variants;

AuthType

integer

user's authentification type, number.

 

Work result

{

 "Cmd" : 16,

 "UIN" : 39

}

 

Field

Type

Value

Cmd

integer

number of a command that was successfully executed, equal to 16 (HEX 0010);

UIN

integer

unique identifier of the created user (UIN).

 

Example of use on PHP language

 '0010',
    'Nick'      => 'JohnSnow',
    'Password'  => 'mysecretword',
    'Email'     => 'johnsnow@winterfell.com',
    'Domain'    => 'circle1.winterfell.com',
    'FirstName' => 'John',
    'LastName'  => 'Snow',
    'MiddleName'=> 'S.',
    'Sex'       => 1,
    'IP'        => '192.168.10.133',
    'NetName'   => 'throne1',
    'ClientType'=> 'web',
    'AuthType'  => 0,
    'APIStype'  => 'php',
    'ServerKey' => 'iddqd'
    )
);

$myCurl = curl_init();
curl_setopt_array($myCurl, array(
    CURLOPT_URL => 'https://192.168.10.133/API/',           // specify an entrance path
    CURLOPT_RETURNTRANSFER => true,                         // return a transfer result as a string
    CURLOPT_SSL_VERIFYHOST => false,                        // disable SSL checking
    CURLOPT_SSL_VERIFYPEER => false,                        // disable SSL checking
    CURLOPT_POST => true,                                   // enabling POST mode
    CURLOPT_HEADER => true,                                 // enabling headers
    CURLOPT_HTTPHEADER => array('integrationapi: mychat'),  // adding a !necessary! header — integrationapi: mychat
    CURLOPT_POSTFIELDS => json_encode($postData)            // enumeration of query data in a JSON format
    ));

$response = curl_exec($myCurl);                             // sending a query

if($response === FALSE){                                    // checking errors
    die(curl_error($myCurl));
}
curl_close($myCurl);                                        // closing a connection

echo $response;                                             // outputing a response

Possible errors

MCIAPI_Error_Nick_Already_Exists

MCIAPI_Error_NickCannotBeEmpty

MCIAPI_Error_WrongIntegrationKey

 

See also

MCIAPI_CS_GetUINByEmail

MCIAPI_CS_GetUINByNick