|
@@ -14,7 +14,8 @@ use think\Db;
|
|
|
*/
|
|
|
class Tenim extends Api
|
|
|
{
|
|
|
- protected $noNeedLogin = ["callback",'test','createIMGroup','updateRoomInfo','setImManage','sendMessageToUser','outMemberFromRoom'];
|
|
|
+ protected $noNeedLogin = ["callback",'test','createIMGroup','updateRoomInfo','setImManage','sendMessageToUser','outMemberFromRoom',
|
|
|
+ 'autoUserLine','getRoomUser','getGroupList','getGroupInfo'];
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
|
|
@@ -184,7 +185,8 @@ exit;
|
|
|
/**
|
|
|
* 获取群组信息
|
|
|
*/
|
|
|
- public function getGroupInfo($party_id) {
|
|
|
+ public function getGroupInfo($party_id='0') {
|
|
|
+ $party_id = !empty($party_id) ? $party_id : $this->request->param('part_id',0);
|
|
|
$random = rand(10000000,99999999);
|
|
|
$usersig = $this->usersig("administrator");
|
|
|
// 获取配置信息
|
|
@@ -198,9 +200,39 @@ exit;
|
|
|
$tencentObj = new tencentim($url);
|
|
|
$data = [];
|
|
|
$data["GroupIdList"] = [$party_id];
|
|
|
- $data["ResponseFilter"] = ["AppDefinedDataFilter_Group"=>[]];
|
|
|
+ $data["ResponseFilter"] = [
|
|
|
+ "GroupBaseInfoFilter" => ["GroupId","Type","Name","FaceUrl","Owner_Account","MemberNum"],
|
|
|
+ "MemberInfoFilter" => ["Account","Role"],
|
|
|
+ "AppDefinedDataFilter_Group" => ["roomInfo"],
|
|
|
+ ];
|
|
|
$groupInfo = $tencentObj->toSend($data);
|
|
|
- return $groupInfo;
|
|
|
+ $this->success('获取成功',$groupInfo['GroupInfo']);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取所有群组
|
|
|
+ */
|
|
|
+ public function getGroupList() {
|
|
|
+ $random = rand(10000000,99999999);
|
|
|
+ $usersig = $this->usersig("administrator");
|
|
|
+ // 获取配置信息
|
|
|
+ $config = config("tencent_im");
|
|
|
+ $url = "https://console.tim.qq.com/v4/group_open_http_svc/get_appid_group_list";
|
|
|
+ $url .= "?sdkappid=".$config["sdkappid"];
|
|
|
+ $url .= "&identifier=administrator";
|
|
|
+ $url .= "&usersig=".$usersig;
|
|
|
+ $url .= "&random==".$random;
|
|
|
+ $url .= "&contenttype=json";
|
|
|
+ $tencentObj = new tencentim($url);
|
|
|
+ $data = [];
|
|
|
+ $data["Limit"] = 100;//本次获取的群组 ID 数量的上限,不得超过 10000。如果不填,默认为最大值 10000
|
|
|
+ $data["GroupType"] = 'AVChatRoom';//群组形态包括 Public(公开群),Private(即 Work,好友工作群),ChatRoom(即 Meeting,会议群),AVChatRoom(音视频聊天室),BChatRoom(在线成员广播大群)和社群(Community)
|
|
|
+ $groupList = $tencentObj->toSend($data);
|
|
|
+ $result = [];
|
|
|
+ if (isset($groupList['ActionStatus']) && $groupList['ActionStatus'] == 'OK') {
|
|
|
+ $result = isset($groupList['GroupIdList']) ? $groupList['GroupIdList'] : [];
|
|
|
+ }
|
|
|
+ $this->success('获取成功',$result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -833,4 +865,103 @@ exit;
|
|
|
$this->sendMessageToUser($from_user,$to_user,$message);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取用户在线更新
|
|
|
+ */
|
|
|
+ public function autoUserLine() {
|
|
|
+ $random = rand(10000000,99999999);
|
|
|
+ $usersig = $this->usersig("administrator");
|
|
|
+ // 获取配置信息
|
|
|
+ $config = config("tencent_im");
|
|
|
+ $url = "https://console.tim.qq.com/v4/openim/query_online_status";
|
|
|
+ $url .= "?sdkappid=".$config["sdkappid"];
|
|
|
+ $url .= "&identifier=administrator";
|
|
|
+ $url .= "&usersig=".$usersig;
|
|
|
+ $url .= "&random=".$random;
|
|
|
+ $url .= "&contenttype=json";
|
|
|
+ $tencentObj = new tencentim($url);
|
|
|
+ // 获取用户
|
|
|
+ $where = [];
|
|
|
+ $userData = model('User')->field('id')->where($where)->order('id asc')->select();
|
|
|
+ $userArr = array_column($userData,'id');
|
|
|
+ $data = [];
|
|
|
+ $data["To_Account"] = $userArr;
|
|
|
+ $result = [];
|
|
|
+ if(!empty($data)) {
|
|
|
+ $result = $tencentObj->toSend($data);
|
|
|
+ if (isset($result['ActionStatus']) && $result['ActionStatus'] == 'OK') {
|
|
|
+ if (isset($result['ErrorList'])) {//没有人员
|
|
|
+ unset($result['ErrorList']);
|
|
|
+ /*foreach ($result['ErrorList'] as $errKey => $errVal) {
|
|
|
+ $userError[] = $errVal['To_Account'];
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+ if (isset($result['QueryResult'])) {
|
|
|
+ $userOnline = $userOffline=[];
|
|
|
+ foreach ($result['QueryResult'] as $key => $value) {
|
|
|
+ if (in_array($value['Status'],['Online','PushOnline'])) {//在线(前台在线和后台在线)
|
|
|
+ $userOnline[] = intval($value['To_Account']);
|
|
|
+ } else {//离线
|
|
|
+ $userOffline[] = intval($value['To_Account']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($userOnline)) {//处理在线
|
|
|
+ $onlineWhere['id'] = ['in',$userOnline];
|
|
|
+ $onlineWhere['is_online'] = 0;
|
|
|
+ model('User')->where($onlineWhere)->update(['is_online'=>1]);
|
|
|
+ }
|
|
|
+ if (!empty($userOffline)) {//处理离线
|
|
|
+ $offlineWhere['id'] = ['in',$userOffline];
|
|
|
+ $offlineWhere['is_online'] = 1;
|
|
|
+ model('User')->where($offlineWhere)->update(['is_online'=>0]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->success('操作成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取房间用户
|
|
|
+ */
|
|
|
+ public function getRoomUser() {
|
|
|
+ $partyIds = $this->request->param('party_ids','');
|
|
|
+ if (!empty($partyIds)) {
|
|
|
+ $partyIds = explode(',',$partyIds);
|
|
|
+ }
|
|
|
+ $random = rand(10000000,99999999);
|
|
|
+ $usersig = $this->usersig("administrator");
|
|
|
+ // 获取配置信息
|
|
|
+ $config = config("tencent_im");
|
|
|
+ $url = "https://console.tim.qq.com/v4/group_open_avchatroom_http_svc/get_members";
|
|
|
+ $url .= "?sdkappid=".$config["sdkappid"];
|
|
|
+ $url .= "&identifier=administrator";
|
|
|
+ $url .= "&usersig=".$usersig;
|
|
|
+ $url .= "&random=".$random;
|
|
|
+ $url .= "&contenttype=json";
|
|
|
+ $tencentObj = new tencentim($url);
|
|
|
+ //获取用户 ["57","62","63","105","106","107","108","109","116","119"]
|
|
|
+ $partyArr = $partyIds;
|
|
|
+ $memberList = [];
|
|
|
+ if(!empty($partyArr)) {
|
|
|
+ foreach ($partyArr as $key => $value) {
|
|
|
+ $data["GroupId"] = $value;
|
|
|
+ $result = $tencentObj->toSend($data);
|
|
|
+ if (isset($result['ActionStatus']) && $result['ActionStatus'] == 'OK') {
|
|
|
+ if (isset($result['MemberList']) && !empty($result['MemberList'])) {
|
|
|
+ foreach ($result['MemberList'] as $ukey => $uval) {
|
|
|
+ $memberList[$value]['member_list'][] = [
|
|
|
+ 'avatar' => $uval['Avatar'],
|
|
|
+ 'user_id'=> $uval['Member_Account'],
|
|
|
+ 'nickname' => $uval['NickName'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $memberList[$value]['online_num'] = count($memberList[$value]['member_list']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $result = $memberList;
|
|
|
+ $this->success('操作成功',$result);
|
|
|
+ }
|
|
|
}
|