新增账户查询接口
This commit is contained in:
parent
888a08e0f8
commit
7aa790b5a3
45
api/api.go
45
api/api.go
@ -45,6 +45,51 @@ func AccountImport(r *AccountImportReq) (*AccountImportAns, error) {
|
||||
return &a, err
|
||||
}
|
||||
|
||||
//账号查询
|
||||
type AccountCheckReq struct {
|
||||
CheckItem []*AccountCheckReqItem `json:"CheckItem"`
|
||||
}
|
||||
type AccountCheckReqItem struct {
|
||||
UserID string `json:"UserID"`
|
||||
}
|
||||
type AccountCheckAns struct {
|
||||
ResultItem []*AccountCheckAnsItem `json:"ResultItem"`
|
||||
}
|
||||
type AccountCheckAnsItem struct {
|
||||
UserID string `json:"UserID"`
|
||||
ResultCode int `json:"ResultCode"`
|
||||
ResultInfo string `json:"ResultInfo"`
|
||||
AccountStatus string `json:"AccountStatus"`
|
||||
}
|
||||
|
||||
func AccountCheck(r *AccountCheckReq) (*AccountCheckAns, error) {
|
||||
a := AccountCheckAns{}
|
||||
err := Api("im_open_login_svc", "account_check", r, &a)
|
||||
return &a, err
|
||||
}
|
||||
|
||||
//账号删除
|
||||
type AccountDeleteReq struct {
|
||||
DeleteItem []*AccountDeleteReqItem `json:"DeleteItem"`
|
||||
}
|
||||
type AccountDeleteReqItem struct {
|
||||
UserID string `json:"UserID"`
|
||||
}
|
||||
type AccountDeleteAns struct {
|
||||
ResultItem []*AccountDeleteAnsItem `json:"ResultItem"`
|
||||
}
|
||||
type AccountDeleteAnsItem struct {
|
||||
UserID string `json:"UserID"`
|
||||
ResultCode int `json:"ResultCode"`
|
||||
ResultInfo string `json:"ResultInfo"`
|
||||
}
|
||||
|
||||
func AccountDelete(r *AccountDeleteReq) (*AccountDeleteAns, error) {
|
||||
a := AccountDeleteAns{}
|
||||
err := Api("im_open_login_svc", "account_delete", r, &a)
|
||||
return &a, err
|
||||
}
|
||||
|
||||
//建群
|
||||
//https://cloud.tencent.com/document/product/269/1615
|
||||
type GroupCreateReq struct {
|
||||
|
71
demo.go
71
demo.go
@ -1,25 +1,76 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
txim "github.com/xucx/txim/api"
|
||||
)
|
||||
|
||||
func main() {
|
||||
txim.Init(1, "xxx", "xxx")
|
||||
sdkAppId, _ := strconv.Atoi(os.Getenv("tximid"))
|
||||
sdkKey := os.Getenv("tximkey")
|
||||
txim.Init(sdkAppId, sdkKey, "administrator")
|
||||
|
||||
//生成签名
|
||||
sig := txim.UserSig("xxx", 300)
|
||||
fmt.Println("签名:", sig)
|
||||
// 生成签名
|
||||
// sig := txim.UserSig("administrator", 300)
|
||||
// fmt.Println("签名:", sig)
|
||||
|
||||
var (
|
||||
data interface{}
|
||||
dataBytes []byte
|
||||
err error
|
||||
)
|
||||
|
||||
//创建房间
|
||||
ans, err := txim.GroupCreate(&txim.GroupCreateReq{
|
||||
OwnerAccount: "administrator",
|
||||
Type: "ChatRoom",
|
||||
Name: "测试聊天室",
|
||||
ApplyJoinOption: "FreeAccess",
|
||||
// data, err = txim.GroupCreate(&txim.GroupCreateReq{
|
||||
// OwnerAccount: "administrator",
|
||||
// Type: "ChatRoom",
|
||||
// Name: "测试聊天室",
|
||||
// ApplyJoinOption: "FreeAccess",
|
||||
// })
|
||||
// dataBytes, _ = json.Marshal(data)
|
||||
// fmt.Printf("%s,%v\n", string(dataBytes), err)
|
||||
|
||||
//创建用户
|
||||
// data, err = txim.AccountImport(&txim.AccountImportReq{
|
||||
// Identifier: "test",
|
||||
// Nick: "test1",
|
||||
// })
|
||||
// dataBytes, _ = json.Marshal(data)
|
||||
// fmt.Printf("%s,%v\n", string(dataBytes), err)
|
||||
|
||||
//查询用户
|
||||
data, err = txim.AccountCheck(&txim.AccountCheckReq{
|
||||
CheckItem: []*txim.AccountCheckReqItem{
|
||||
{UserID: "test"},
|
||||
},
|
||||
})
|
||||
fmt.Printf("创建房间结果:%v,%+v\n", err, ans)
|
||||
dataBytes, _ = json.Marshal(data)
|
||||
fmt.Printf("%s,%v\n", string(dataBytes), err)
|
||||
|
||||
//删除用户
|
||||
// data, err = txim.AccountDelete(&txim.AccountDeleteReq{
|
||||
// DeleteItem: []*txim.AccountDeleteReqItem{
|
||||
// {UserID: "test"},
|
||||
// },
|
||||
// })
|
||||
// dataBytes, _ = json.Marshal(data)
|
||||
// fmt.Printf("%s,%v\n", string(dataBytes), err)
|
||||
|
||||
//设置用户资料
|
||||
// data, err = txim.ProfileSet(&txim.ProfileSetReq{
|
||||
// FromAccount: "test1",
|
||||
// ProfileItem: []*txim.ProfileSetReqItem{
|
||||
// {
|
||||
// Tag: "Tag_Profile_IM_Nick",
|
||||
// Value: "test1",
|
||||
// },
|
||||
// },
|
||||
// })
|
||||
// dataStr, _ := json.Marshal(data)
|
||||
// fmt.Printf("%+v,%v\n", dataStr, err)
|
||||
|
||||
}
|
||||
|
1
go.mod
1
go.mod
@ -5,4 +5,5 @@ go 1.13
|
||||
require (
|
||||
github.com/imroc/req v0.3.0
|
||||
github.com/tencentyun/tls-sig-api-v2-golang v1.0.0
|
||||
gopkg.in/square/go-jose.v2 v2.5.0 // indirect
|
||||
)
|
||||
|
2
go.sum
2
go.sum
@ -2,3 +2,5 @@ github.com/imroc/req v0.3.0 h1:3EioagmlSG+z+KySToa+Ylo3pTFZs+jh3Brl7ngU12U=
|
||||
github.com/imroc/req v0.3.0/go.mod h1:F+NZ+2EFSo6EFXdeIbpfE9hcC233id70kf0byW97Caw=
|
||||
github.com/tencentyun/tls-sig-api-v2-golang v1.0.0 h1:NavMw9XO2iCLv8hTKaJW2kTaGR2SdNljMABbe39yu6Q=
|
||||
github.com/tencentyun/tls-sig-api-v2-golang v1.0.0/go.mod h1:u7WiArmCTXTaQAHJwAOaLgpJ5e2xdY5/cgMEy3ubL60=
|
||||
gopkg.in/square/go-jose.v2 v2.5.0 h1:OZ4sdq+Y+SHfYB7vfthi1Ei8b0vkP8ZPQgUfUwdUSqo=
|
||||
gopkg.in/square/go-jose.v2 v2.5.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
|
||||
|
Loading…
Reference in New Issue
Block a user