txim/txim.go

33 lines
673 B
Go
Raw Permalink Normal View History

2022-01-11 10:14:11 +08:00
package txim
import "github.com/tencentyun/tls-sig-api-v2-golang/tencentyun"
const (
ApiHost = "console.tim.qq.com" // API服务器地址
ApiVersion = "v4" // API版本号
)
var g struct {
sdkAppID int
identifier string
key string
}
// GetInfo 获取SDK AppID等信息
func GetInfo() (int, string) {
return g.sdkAppID, g.identifier
}
// Init 初始化SDK
func Init(sdkAppID int, key, identifier string) {
g.sdkAppID = sdkAppID
g.key = key
g.identifier = identifier
}
// UserSig 生成签名
func UserSig(identifier string, expire int) string {
sig, _ := tencentyun.GenUserSig(g.sdkAppID, g.key, identifier, expire)
return sig
}