diff --git a/application/api/model/Tencent.php b/application/api/model/Tencent.php index 585f327..448a87d 100644 --- a/application/api/model/Tencent.php +++ b/application/api/model/Tencent.php @@ -726,6 +726,35 @@ class Tencent extends Model return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null]; } } + + //修改用户信息 + public function modify_user_info($member_id, $member_name = '', $member_face_url = '') + { + $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); + $postUrl = 'https://console.tim.qq.com/v4/profile/portrait_set?sdkappid='.$tencentyun_im_appid.'&identifier='.$im_admin.'&usersig='.$admin_sig.'&random='.$rand.'&contenttype=json'; + $curlPost['From_Account'] = $member_id; + $curlPost['ProfileItem'] = [ + [ + 'Tag' => 'Tag_Profile_IM_Nick', + 'Value' => $member_name + ], + [ + 'Tag' => 'Tag_Profile_IM_Image', + 'Value' => $member_face_url + ] + ]; + $curlPost = json_encode($curlPost); + $reslut = $this->tencent_post_url($postUrl, $curlPost); + if($reslut['ActionStatus'] == 'OK'){ + return ['code' => 1, 'msg' => '操作成功', 'data' => null]; + }else{ + return ['code' => 0, 'msg' => $reslut['ErrorCode'], 'data' => null]; + } + } //====新写的↓=====上面的 能用则用============================================================================================================= diff --git a/application/api/model/User.php b/application/api/model/User.php index d6176b4..edc18c3 100644 --- a/application/api/model/User.php +++ b/application/api/model/User.php @@ -713,6 +713,12 @@ class User extends Model $text['text'] = '用户 ' . $text['FromUserInfo']['nickname'] .' 修改了信息'; model('Chat')->sendMsg(1035,$room_id,$text,$user_id); } + + //给腾讯同步用户信息 + $member_name = db::name('user')->where('id' , $user_id)->value('nickname'); + $member_face_url = db::name('user')->where('id' , $user_id)->value('avatar'); + model('Tencent')->modify_user_info($user_id, $member_name, $member_face_url); + return ['code' => 1, 'msg' => '修改成功', 'data' => null]; } catch(\Exception $e){ diff --git a/application/api/model/UserData.php b/application/api/model/UserData.php index 4fe278b..e1a9299 100644 --- a/application/api/model/UserData.php +++ b/application/api/model/UserData.php @@ -82,7 +82,10 @@ class UserData extends Model $reslut = model('User')->update($data); if ($reslut) { $user_info = model('User')->where('id', $uid)->field('id,nickname,avatar,user_code')->find(); - + //给腾讯同步用户信息 + $member_name = $user_info['nickname']; + $member_face_url = $user_info['avatar']; + model('Tencent')->modify_user_info($uid, $member_name, $member_face_url); return ['code' => 1, 'msg' => '修改成功', 'data' => $user_info]; } else { return ['code' => 0, 'msg' => '修改失败,','data' =>null];