Browse Source

退出登录,退出im

lizhen_gitee 3 years ago
parent
commit
8a50677b49
2 changed files with 55 additions and 1 deletions
  1. 51 1
      application/api/controller/Tenim.php
  2. 4 0
      application/api/controller/User.php

+ 51 - 1
application/api/controller/Tenim.php

@@ -14,7 +14,7 @@ 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','selectstatus','loginoutim'];
     protected $noNeedRight = ['*'];
 
 
@@ -37,6 +37,56 @@ exit;
 //        $this->success("",$partyList);
     }
 
+    public function loginoutim($uid){
+        /*
+         * https://console.tim.qq.com/v4/im_open_login_svc/kick?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
+         */
+        $random = rand(10000000, 99999999);
+        $usersig = $this->usersig("administrator");
+        // 获取配置信息
+        $config = config("tencent_im");
+        $url = "https://console.tim.qq.com/v4/im_open_login_svc/kick";
+        $url .= "?sdkappid=" . $config["sdkappid"];
+        $url .= "&identifier=administrator";
+        $url .= "&usersig=" . $usersig;
+        $url .= "&random=" . $random;
+        $url .= "&contenttype=json";
+
+        $data = [
+            'Identifier' => "".$uid."",
+        ];
+
+        $rs = curl_post($url,json_encode($data));
+        //dump($rs);
+//        exit;
+
+    }
+    public function selectstatus(){
+        /*
+         * https://console.tim.qq.com/v4/openim/query_online_status?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
+         */
+        $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";
+
+        $data = [
+            'To_Account' => ["34"],
+        ];
+
+        $rs = curl_post($url,json_encode($data));
+        //$rs = curl_post($url,'{"IsNeedDetail":1,"To_Account":["32"]}');
+        dump($rs);
+        exit;
+
+    }
+
     /**
      * 创建im群组
      */

+ 4 - 0
application/api/controller/User.php

@@ -235,6 +235,10 @@ class User extends Api
         if (!$this->request->isPost()) {
             $this->error(__('Invalid parameters'));
         }
+        //退出im
+        $tenIm = new Tenim();
+        $tenIm->loginoutim($this->auth->id);
+
         $this->auth->logout();
         $this->success(__('Logout successful'));
     }