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",
"context" : "myfunc"
"ID" : 1
}
Parameters
Parameter |
Type |
Value |
cmd |
string |
"0015", number of the command MCIAPI_CS_GetWebSupportGroupUsersList; |
ServerKey |
string |
IntegrationAPI key, can be set in the server settings; |
APIStype |
string |
integration type. You can set any string; |
context |
string |
optional parameter, any text that returns in response command; |
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",
"ID" : 1
"UINS" : "21,13,6"
}
Field |
Type |
Value |
cmd |
integer |
number of a command that was successfully executed, equal to 21 (HEX 000F); |
context |
|
any text sent to the server in a query command; |
ID |
integer |
support group ID; |
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.
<?php
$host = 'mychat-server.com';
$portWEB = '443';
$isUseHttps = true;
$integrationAPIKey = 'secretKey';
$toolName = 'php';
$protocol = ($isUseHttps ? 'https' : 'http');
$getUsersByGroupID = '0015';
$getUsersStatesList = '000F';
$groupID = 1;
$URL = $protocol.'://'.$host.':'.$portWEB.'/API/?data=';
$jsonGetUsers = urlencode(json_encode(array('cmd'=>$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
#5, MCIAPI_Error_WrongIntegrationKey
#10, MCIAPI_Error_ParameterAbsent
#50, MCIAPI_Error_WebSupportGroupIDNotExists