|
@@ -238,4 +238,74 @@ class TenimService
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建用户账号
|
|
|
+ */
|
|
|
+ public function accountImport($params=[])
|
|
|
+ {
|
|
|
+ $result = [
|
|
|
+ 'status' => 1,
|
|
|
+ 'msg' => '获取成功',
|
|
|
+ 'data' => [],
|
|
|
+ ];
|
|
|
+ try {
|
|
|
+ $userId = isset($params['user_id']) ? $params['user_id'] : 0;
|
|
|
+ $nickname = isset($params['nickname']) ? $params['nickname'] : '';
|
|
|
+ $avatar = isset($params['avatar']) ? $params['avatar'] : '';
|
|
|
+
|
|
|
+ $url = "https://console.tim.qq.com/v4/im_open_login_svc/account_import".$this->url;
|
|
|
+ $tencentObj = new tencentim($url);
|
|
|
+ if(!empty($userId)) {
|
|
|
+ $data["UserID"] = (string)$userId;
|
|
|
+ $data["Nick"] = $nickname;
|
|
|
+ $data["FaceUrl"] = $avatar;
|
|
|
+ $imRes = $tencentObj->toSend($data);
|
|
|
+ if (isset($imRes['ActionStatus']) && $imRes['ActionStatus'] != 'OK') {
|
|
|
+ $errorInfo = isset($imRes['ErrorInfo']) ? $imRes['ErrorInfo'] : [];
|
|
|
+ throw new Exception(json_encode($errorInfo));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $result['status'] = 0;
|
|
|
+ $result['msg'] = $e->getMessage();
|
|
|
+ }
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询用户账号
|
|
|
+ */
|
|
|
+ public function accountCheck($params=[])
|
|
|
+ {
|
|
|
+ $result = [
|
|
|
+ 'status' => 1,
|
|
|
+ 'msg' => '获取成功',
|
|
|
+ 'data' => [],
|
|
|
+ ];
|
|
|
+ try {
|
|
|
+ $userIds = isset($params['user_ids']) ? $params['user_ids'] : [];
|
|
|
+
|
|
|
+ if(!empty($userIds)) {
|
|
|
+ $url = "https://console.tim.qq.com/v4/im_open_login_svc/account_check".$this->url;
|
|
|
+ $tencentObj = new tencentim($url);
|
|
|
+ foreach ($userIds as $key => $value) {
|
|
|
+ $userIdArr[] = [
|
|
|
+ 'UserID' => $value,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $data["CheckItem"] = $userIdArr;
|
|
|
+ $imRes = $tencentObj->toSend($data);
|
|
|
+ if (isset($imRes['ActionStatus']) && $imRes['ActionStatus'] != 'OK') {
|
|
|
+ $errorInfo = isset($imRes['ErrorInfo']) ? $imRes['ErrorInfo'] : [];
|
|
|
+ throw new Exception(json_encode($errorInfo));
|
|
|
+ }
|
|
|
+ $result['data'] = isset($imRes['ResultItem']) ? $imRes['ResultItem'] : [];
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $result['status'] = 0;
|
|
|
+ $result['msg'] = $e->getMessage();
|
|
|
+ }
|
|
|
+ return $result;
|
|
|
+ }
|
|
|
}
|