房间在线人数 状态 使用腾讯回调
This commit is contained in:
@@ -1264,63 +1264,76 @@ class Room extends Model
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
|
||||
//查找数据库用户
|
||||
$dblist = db::name('vs_room_visitor')->where(['room_id' => $room_id])->field('user_id')->select();
|
||||
//循环获取在线用户ID 拼接数据
|
||||
$user_id_array = [];
|
||||
//机器人user_id
|
||||
$robot_user_id = [];
|
||||
foreach ($dblist as $v) {
|
||||
//机器人
|
||||
if(db::name('user')->where(['id' => $v['user_id']])->value('is_robot')){
|
||||
$robot_user_id[] = $v['user_id'];
|
||||
continue;
|
||||
}
|
||||
$user_id_array[] = 'u'.$v['user_id'];
|
||||
}
|
||||
//获取腾讯的在线用户
|
||||
$online_users = model('Tencent')->query_user_online_status($user_id_array);
|
||||
$online_user = [];
|
||||
if(isset($online_users['ActionStatus']) && $online_users['ActionStatus'] == 'OK'){
|
||||
if($online_users['QueryResult']){
|
||||
foreach ($online_users['QueryResult'] as $v){
|
||||
if($v['Status'] == "Online"){
|
||||
//截取用户ID前面的 u 并获取用户ID
|
||||
$user_id = substr($v['To_Account'],1);
|
||||
$online_user[] = $user_id;
|
||||
}
|
||||
//获取在房间的用户
|
||||
$in_room_users = db::name('vs_room_visitor')->where(['room_id' => $room_id])->field('user_id')->select();
|
||||
if($in_room_users){
|
||||
foreach ($in_room_users as $v){
|
||||
$userss = db::name('user')->where(['id' => $v['user_id']])->field('is_online,is_robot')->find();
|
||||
if($userss['is_online'] == 1 && $userss['is_robot'] == 1){//在线或者机器人都设置为在线
|
||||
db::name('vs_room_visitor')->where(['id' => $v['id']])->update(['on_line' => 1]);
|
||||
}else{
|
||||
db::name('vs_room_visitor')->where(['id' => $v['id']])->update(['on_line' => 0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($dblist){
|
||||
$onpit = db::name('vs_room_pit')->field('user_id')->where(['room_id' => $room_id])->select();
|
||||
//合并数组
|
||||
$array = array_merge($online_user,$robot_user_id);
|
||||
// $array = $online_user;
|
||||
$arraypit = array_values((array)$onpit);
|
||||
foreach ($dblist as &$v){
|
||||
// if(in_array($v['user_id'],$arraypit)){
|
||||
// //跳过本次循环
|
||||
// continue;
|
||||
// //查找数据库用户
|
||||
// $dblist = db::name('vs_room_visitor')->where(['room_id' => $room_id])->field('user_id')->select();
|
||||
// //循环获取在线用户ID 拼接数据
|
||||
// $user_id_array = [];
|
||||
// //机器人user_id
|
||||
// $robot_user_id = [];
|
||||
// foreach ($dblist as $v) {
|
||||
// //机器人
|
||||
// if(db::name('user')->where(['id' => $v['user_id']])->value('is_robot')){
|
||||
// $robot_user_id[] = $v['user_id'];
|
||||
// continue;
|
||||
// }
|
||||
// $user_id_array[] = 'u'.$v['user_id'];
|
||||
// }
|
||||
// //获取腾讯的在线用户
|
||||
// $online_users = model('Tencent')->query_user_online_status($user_id_array);
|
||||
// $online_user = [];
|
||||
// if(isset($online_users['ActionStatus']) && $online_users['ActionStatus'] == 'OK'){
|
||||
// if($online_users['QueryResult']){
|
||||
// foreach ($online_users['QueryResult'] as $v){
|
||||
// if($v['Status'] == "Online"){
|
||||
// //截取用户ID前面的 u 并获取用户ID
|
||||
// $user_id = substr($v['To_Account'],1);
|
||||
// $online_user[] = $user_id;
|
||||
// }
|
||||
// }
|
||||
if(!in_array($v['user_id'],$array)){
|
||||
//修改他的状态
|
||||
db::name('vs_room_visitor')->where(['user_id' => $v['user_id'],'room_id'=>$room_id])->update(['on_line' => 0]);
|
||||
//查询他是否在其他房间
|
||||
$room_id_list = db::name('vs_room_visitor')->where(['user_id' => $v['user_id'],'room_id'=>['neq',$room_id]])->find();
|
||||
if($room_id_list){
|
||||
db::name('vs_room_visitor')->where(['user_id' => $v['user_id']])->delete();
|
||||
}
|
||||
}else{
|
||||
//修改他的状态
|
||||
db::name('vs_room_visitor')->where(['user_id' => $v['user_id'],'room_id'=>$room_id])->update(['on_line' => 1]);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$lists = ['on_pit' => [], 'off_pit' => []];
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $lists];
|
||||
}
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if($dblist){
|
||||
// $onpit = db::name('vs_room_pit')->field('user_id')->where(['room_id' => $room_id])->select();
|
||||
// //合并数组
|
||||
// $array = array_merge($online_user,$robot_user_id);
|
||||
//// $array = $online_user;
|
||||
// $arraypit = array_values((array)$onpit);
|
||||
// foreach ($dblist as &$v){
|
||||
//// if(in_array($v['user_id'],$arraypit)){
|
||||
//// //跳过本次循环
|
||||
//// continue;
|
||||
//// }
|
||||
// if(!in_array($v['user_id'],$array)){
|
||||
// //修改他的状态
|
||||
// db::name('vs_room_visitor')->where(['user_id' => $v['user_id'],'room_id'=>$room_id])->update(['on_line' => 0]);
|
||||
// //查询他是否在其他房间
|
||||
// $room_id_list = db::name('vs_room_visitor')->where(['user_id' => $v['user_id'],'room_id'=>['neq',$room_id]])->find();
|
||||
// if($room_id_list){
|
||||
// db::name('vs_room_visitor')->where(['user_id' => $v['user_id']])->delete();
|
||||
// }
|
||||
// }else{
|
||||
// //修改他的状态
|
||||
// db::name('vs_room_visitor')->where(['user_id' => $v['user_id'],'room_id'=>$room_id])->update(['on_line' => 1]);
|
||||
// }
|
||||
// }
|
||||
// }else{
|
||||
// $lists = ['on_pit' => [], 'off_pit' => []];
|
||||
// return ['code' => 1, 'msg' => '成功', 'data' => $lists];
|
||||
// }
|
||||
|
||||
|
||||
$list = db::name('vs_room_visitor')->alias('a')
|
||||
@@ -1348,7 +1361,7 @@ class Room extends Model
|
||||
});
|
||||
}
|
||||
|
||||
if(($label_type['data']['type_id'] == 1 || $label_type['data']['type_id'] == 3 || $label_type['data']['type_id'] == 4) && $label_type['data']['label_id'] == 1) {//2卡八麦(聊天)type_id = 1,label_id = 1
|
||||
if($label_type['data']['type_id'] == 7 || ($label_type['data']['type_id'] == 1 || $label_type['data']['type_id'] == 3 || $label_type['data']['type_id'] == 4) && $label_type['data']['label_id'] == 1) {//2卡八麦(聊天)type_id = 1 || 7(交友),label_id = 1
|
||||
foreach ($list as &$val) {
|
||||
if ($val['pit_number'] > 0) {
|
||||
$lists['on_pit'][] = $val;
|
||||
|
||||
@@ -7,12 +7,11 @@ use fast\Http;
|
||||
use think\Db;
|
||||
use think\Log;
|
||||
use think\Model;
|
||||
use think\facade\Env;
|
||||
use fast\Tencentst;
|
||||
|
||||
class Tencent extends Model
|
||||
{
|
||||
|
||||
|
||||
//获取腾讯IM UserSig信息
|
||||
//$uid => 用户id
|
||||
public function tencent_user_sig_info($uid){
|
||||
@@ -40,7 +39,7 @@ class Tencent extends Model
|
||||
'UserID' => 'u'.$uid,
|
||||
'Nick' => '',
|
||||
'FaceUrl' => '',
|
||||
);
|
||||
);
|
||||
if($data){
|
||||
//添加用户信息 昵称和头像
|
||||
$curlPost['Nick'] = $data['nick'];
|
||||
@@ -100,7 +99,7 @@ class Tencent extends Model
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => $reslut];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//查询账号
|
||||
//$uid => 用户id
|
||||
public function account_check($uid){
|
||||
@@ -109,19 +108,19 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/im_open_login_svc/account_check?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'CheckItem' => array(
|
||||
array(
|
||||
'UserID' => 'u'.$uid, //
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
),
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
// var_dump($reslut);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
@@ -135,7 +134,7 @@ class Tencent extends Model
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//拉入黑名单
|
||||
public function black_list_add($uid, $receive_uid){
|
||||
$config = get_system_config();
|
||||
@@ -143,16 +142,16 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/sns/black_list_add?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'From_Account' => $uid,
|
||||
'To_Account' => [$receive_uid],
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("腾讯用户拉入黑名单".json_encode($reslut),"infos");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
@@ -161,7 +160,7 @@ class Tencent extends Model
|
||||
return ['code' => 201, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//移除黑名单
|
||||
public function black_list_delete($uid, $receive_uid){
|
||||
$config = get_system_config();
|
||||
@@ -169,16 +168,16 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/sns/black_list_delete?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'From_Account' => $uid,
|
||||
'To_Account' => [$receive_uid],
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 200, 'msg' => '移除成功', 'data' => null];
|
||||
@@ -186,7 +185,7 @@ class Tencent extends Model
|
||||
return ['code' => 201, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//发送群内系统消息
|
||||
public function send_group_system_notification($rid, $message_data){
|
||||
Log::record("腾讯群内系统消息发送结果".json_encode($rid.$message_data),"info");
|
||||
@@ -197,11 +196,11 @@ class Tencent extends Model
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/send_group_system_notification?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'GroupId' => $rid,
|
||||
'Content' => $message_data,
|
||||
);
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
@@ -251,19 +250,19 @@ class Tencent extends Model
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => $reslut];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//发送群内普通消息
|
||||
public function send_group_msg($rid, $message_data, $uid=''){
|
||||
|
||||
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$random = time().rand(111,999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/send_group_msg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'GroupId' => $rid,
|
||||
'From_Account' => $uid,
|
||||
@@ -273,18 +272,18 @@ class Tencent extends Model
|
||||
'MsgType' => 'TIMTextElem',
|
||||
'MsgContent' => array(
|
||||
'Text' => $message_data,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
),
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
// $txt = date('Y-m-d H:i:s').'测试';
|
||||
// error_log($txt, 3, 'a.txt');
|
||||
return $reslut;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -306,8 +305,8 @@ class Tencent extends Model
|
||||
'GroupId' => strval($rid),
|
||||
'Name' => $group_name,
|
||||
'FaceUrl' => $url
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
|
||||
@@ -338,7 +337,7 @@ class Tencent extends Model
|
||||
'Member_Account' => 'u'.$uid,
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
@@ -360,7 +359,7 @@ class Tencent extends Model
|
||||
$curlPost = array(
|
||||
'GroupId' => strval($rid),
|
||||
'MemberToDel_Account' => array(
|
||||
'u'.$uid
|
||||
'u'.$uid
|
||||
),
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
@@ -383,7 +382,7 @@ class Tencent extends Model
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/destroy_group?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost = array(
|
||||
'GroupId' => strval($rid),
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
@@ -392,7 +391,7 @@ class Tencent extends Model
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//指定用户发送消息给用户
|
||||
public function user_sendmsg($uid, $receive_uid, $message, $machine_type = 2, $OnlineOnlyFlag = 0){
|
||||
$config = get_system_config();
|
||||
@@ -400,7 +399,7 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/openim/sendmsg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
$curlPost = array(
|
||||
@@ -413,16 +412,16 @@ class Tencent extends Model
|
||||
'MsgType' => 'TIMTextElem',
|
||||
'MsgContent' => array(
|
||||
'Text' => $message,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
if($OnlineOnlyFlag == 1){
|
||||
$curlPost['OnlineOnlyFlag'] = 1;
|
||||
}
|
||||
Log::record("xitong消息信息1:".$admin_sig,"info");
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("xitong消息信息2:".$reslut,"info");
|
||||
return $reslut;
|
||||
@@ -457,7 +456,7 @@ class Tencent extends Model
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
//获取APP中的所有群组
|
||||
public function get_appid_group_list(){
|
||||
$config = get_system_config();
|
||||
@@ -465,40 +464,40 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/get_appid_group_list?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'Limit' => 20,
|
||||
'Next' => 0,
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function txt(){
|
||||
$postUrl = 'https://app.yayinyy.com/api/Agora/get_sstoken';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'code' => '44863d01cd628e583efeb3b9eda510fd',
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
//腾讯IM请求封装方法
|
||||
public function tencent_post_url($postUrl, $curlPost){
|
||||
|
||||
|
||||
$headerArray =array(
|
||||
"Content-type:application/json",
|
||||
"Accept:application/json",
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$ch = curl_init();//初始化curl
|
||||
curl_setopt($ch, CURLOPT_URL, $postUrl);//抓取指定网页
|
||||
// curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
|
||||
@@ -515,7 +514,7 @@ class Tencent extends Model
|
||||
// dump($data);exit;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
//指定用户发送自定义消息给注册用户
|
||||
public function user_custom_sendmsg($uid, $receive_uid, $message, $machine_type = 2){
|
||||
$config = get_system_config();
|
||||
@@ -523,9 +522,9 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/openim/sendmsg?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'SyncOtherMachine' => $machine_type,
|
||||
'From_Account' => strval($uid),
|
||||
@@ -538,16 +537,16 @@ class Tencent extends Model
|
||||
// 'Text' => $message,
|
||||
'Data' => $message,
|
||||
// 'Desc' => 'notification',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
//获取用户在线状态
|
||||
public function query_user_online_status($to_uid_arr)
|
||||
{
|
||||
@@ -559,16 +558,16 @@ class Tencent extends Model
|
||||
$im_admin = 'administrator';
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/openim/query_online_status?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'To_Account' => $to_uid_arr,
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
|
||||
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
@@ -582,13 +581,13 @@ class Tencent extends Model
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/get_online_member_num?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost = array(
|
||||
'GroupId' => 'room'.$group_id,
|
||||
);
|
||||
);
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
return $reslut;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//主动审核接口
|
||||
public function content_moderation($type_name, $content){
|
||||
return ['code' => 1, 'msg' => '通过审核', 'data' => null];
|
||||
@@ -598,17 +597,17 @@ class Tencent extends Model
|
||||
$admin_sig = $this->tencent_user_sig_info($im_admin);
|
||||
$rand = rand(111111111,9999999999);
|
||||
$random = time().rand(111,999);
|
||||
|
||||
|
||||
$postUrl = 'https://console.tim.qq.com/v4/im_msg_audit/content_moderation?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
|
||||
|
||||
$curlPost = array(
|
||||
'AuditName' => 'C2C', //表明送审策略,取值:C2C/Group/UserInfo/GroupInfo/GroupMemberInfo/RelationChain
|
||||
'ContentType' => $type_name, //送审类型,取值:Text/Image/Audio/Video。
|
||||
'Content' => $content //送审内容,最大限制8KB,当审核文件时,填对应 URL。其中图片审核最大不超过5MB
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
$curlPost = json_encode($curlPost);
|
||||
|
||||
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
if($reslut['Result'] == 'Pass'){
|
||||
@@ -656,14 +655,14 @@ class Tencent extends Model
|
||||
$postUrl = 'https://console.tim.qq.com/v4/group_open_http_svc/modify_group_base_info?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json';
|
||||
$curlPost['GroupId'] = $group_id;
|
||||
if($group_name){
|
||||
$curlPost['Name'] = $group_name;
|
||||
}
|
||||
if($group_face_url){
|
||||
$curlPost['FaceUrl'] = $group_face_url;
|
||||
}
|
||||
if($group_notice){
|
||||
$curlPost['Notification'] = $group_notice;
|
||||
}
|
||||
$curlPost['Name'] = $group_name;
|
||||
}
|
||||
if($group_face_url){
|
||||
$curlPost['FaceUrl'] = $group_face_url;
|
||||
}
|
||||
if($group_notice){
|
||||
$curlPost['Notification'] = $group_notice;
|
||||
}
|
||||
// $curlPost = array(
|
||||
// 'GroupId' => $group_id,
|
||||
// 'Name' => $group_name,//群名称
|
||||
@@ -693,7 +692,7 @@ class Tencent extends Model
|
||||
$curlPost['GroupId'] = $group_id;
|
||||
$curlPost['Member_Account'] = $member_id;//群成员帐号
|
||||
if($member_role == 1){
|
||||
$curlPost['Role'] = 'Admin';//群成员角色,取值:Owner(群主),Admin(群管理员),Member(普通群成员)
|
||||
$curlPost['Role'] = 'Admin';//群成员角色,取值:Owner(群主),Admin(群管理员),Member(普通群成员)
|
||||
}elseif ($member_role == 2){
|
||||
$curlPost['Role'] = 'Member';
|
||||
}
|
||||
@@ -728,7 +727,7 @@ class Tencent extends Model
|
||||
}
|
||||
|
||||
//修改用户信息
|
||||
public function modify_user_infos($member_id, $member_name, $member_face_url)
|
||||
public function modify_user_infos($member_id, $member_name = '', $member_face_url = '')
|
||||
{
|
||||
$config = get_system_config();
|
||||
$tencentyun_im_appid = $config['tencentyun_im_appid'];
|
||||
@@ -749,14 +748,13 @@ class Tencent extends Model
|
||||
];
|
||||
$curlPost = json_encode($curlPost);
|
||||
$reslut = $this->tencent_post_url($postUrl, $curlPost);
|
||||
Log::record("修改用户信息:".json_encode($reslut),"infos");
|
||||
if($reslut['ActionStatus'] == 'OK'){
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}else{
|
||||
return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//====新写的↓=====上面的 能用则用=============================================================================================================
|
||||
|
||||
// 获取 Access Token(需缓存并定时刷新,每20分钟一次)
|
||||
@@ -888,5 +886,49 @@ class Tencent extends Model
|
||||
}
|
||||
}
|
||||
|
||||
//腾讯IM回调
|
||||
public function tencent_call_back($data,$sign_data){
|
||||
//回调鉴权
|
||||
// $token = '2k1j90av9rtl2ozbnbqxzyrtuj4a4oy5';
|
||||
// $sign = sha256($token.$sign_data['RequestTime']);
|
||||
// // $datas = json_encode($data);
|
||||
// // error_log($datas, 3, '1.txt');
|
||||
// // $sign_datas = json_encode($sign_data);
|
||||
// if($sign != $sign_data['Sign']){
|
||||
// return ['ActionStatus' => 'FAIL', 'ErrorInfo' => '', 'ErrorCode' => 1];
|
||||
// }
|
||||
// dump($data);exit;
|
||||
|
||||
|
||||
//在线状态更新
|
||||
if($data['CallbackCommand'] == 'State.StateChange'){
|
||||
$info = $data['Info'];
|
||||
$reslut = $this->tencent_member_status_change($info);
|
||||
}
|
||||
return ['ActionStatus' => 'OK', 'ErrorInfo' => '', 'ErrorCode' => 0];
|
||||
}
|
||||
|
||||
//腾讯IM监控在线状态更新
|
||||
public function tencent_member_status_change($info){
|
||||
$uid = substr($info['To_Account'],1);
|
||||
$action = $info['Action'];
|
||||
|
||||
if($action == 'Disconnect') {
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
$quit_room = Db::name('vs_room_visitor')->where('user_id', $uid)->select();
|
||||
|
||||
if($quit_room) {
|
||||
foreach ($quit_room as &$v){
|
||||
model('Room')->quit_room($v['user_id'], $v['room_id'],$v['user_id']);
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ($action == 'Login') {
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 1, 'updatetime' => time()]);
|
||||
}elseif ($action == 'Logout'){
|
||||
Db::name('user')->where('id', $uid)->update(['is_online' => 0, 'updatetime' => time()]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user