MyChat Integration API: MCIAPI_CS_GetWebSupportGroupUsersList, get a list of user UINs

MyChat Integration API: MCIAPI_CS_GetWebSupportGroupUsersList, get a list of user UINs

Get a list of user UINs for a specified group of website WEB support.

 

Syntax

{

 "cmd"       : "0015",

 "ServerKey" : "iddqd",

 "APIStype"  : "mydata",

 

 "ID"        : 1

}

 

Parameter

Parameter

Type

Value

ServerKey

string

IntegrationAPI key, can be set in the server settings;

APIStype

string

integration type. You can set any string;

ID

integer

numeric identifier of WEB support group (you can see it in the list of groups in the "Tools", "Support button to website"

 

Work result

{

 "cmd"      : "0015",

 "UINS"     : "21,13,6"

}

 

Field

Type

Value

Cmd

integer

number of a command that was successfully executed, equal to 21 (HEX 000F);

UINs

string

list of user numeric identifiers divided by commas. If a group number is invalid then an empty string returns.

 

Example of use on PHP language

The script gets a list of users from a specified group, obtains their statuses and then connect to one of the online users. If all users are online the script connects to a random user.

 


$getUsersByGroupID, 'ID' =>$groupID, 'APIStype'=>$toolName, 'ServerKey'=>$integrationAPIKey)));
$usersResult = file_get_contents($URL . $jsonGetUsers);
$jsonUsers = json_decode($usersResult, true);
$users = $jsonUsers['UINS'];
$jsonGetUsersStates = urlencode(json_encode(array('cmd'=>$getUsersStatesList, 'UINS' =>$users, 'APIStype'=>$toolName, 'ServerKey'=>$integrationAPIKey)));
$statesResult = json_decode(file_get_contents($URL . $jsonGetUsersStates), true);

if(isset($statesResult['Error'])){
	echo 'Error=' . $statesResult['Error'];	
}else if(isset($statesResult['Statuses'])){
	$UINS = explode(',', $statesResult['UINS']);
	$states = explode(',', $statesResult['Statuses']);
	$onlines = array();
	for($i = 0; $i < count($states); $i++){
		if($states[$i] != -1){
			array_push($onlines, $UINS[$i]);	
		}
	}
	$target = (empty($onlines) ? $UINS[array_rand($UINS)] : $onlines[array_rand($onlines)]);
	$result = $protocol.'://'.$host.':'.$portWEB.'/support/?uin='.$target;
	header("Location: ".$result);
	exit();
}
?>

 

Possible errors

MCIAPI_Error_WrongIntegrationKey

 

See also

MCIAPI_CS_GetUsersStatusList