douyin

package module
v0.0.0-...-95bb97b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 13 Imported by: 0

README

douyin

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultLogger

type DefaultLogger struct{}

func (DefaultLogger) Error

func (l DefaultLogger) Error(args ...any)

func (DefaultLogger) Errorf

func (l DefaultLogger) Errorf(template string, args ...any)

type JsCode2SessionData

type JsCode2SessionData struct {
	SessionKey      string `json:"session_key"`
	Openid          string `json:"openid"`
	AnonymousOpenid string `json:"anonymous_openid"`
	Unionid         string `json:"unionid"`
}

type JsCode2SessionReq

type JsCode2SessionReq struct {
	AppID         string `json:"appid"`
	Secret        string `json:"secret"`
	Code          string `json:"code"`
	AnonymousCode string `json:"anonymous_code"`
}

JsCode2SessionReq 登录凭证校验请求参数

type JsCode2SessionResp

type JsCode2SessionResp struct {
	ErrNo   int                 `json:"err_no"`
	ErrTips string              `json:"err_tips"`
	Data    *JsCode2SessionData `json:"data"`
	AppID   string
}

JsCode2SessionResp 登录凭证校验的返回结果

type Logger

type Logger interface {
	Error(args ...any)
	Errorf(template string, args ...any)
}

type NotifyReq

type NotifyReq struct {
	AccessToken string            `json:"access_token"` // 必选, 小程序 access_token
	AppID       string            `json:"app_id"`       // 必选, 小程序的 id
	TplID       string            `json:"tpl_id"`       // 必选, 模板的 id
	OpenID      string            `json:"open_id"`      // 必选, 接收消息目标用户的 open_id
	Data        map[string]string `json:"data"`         // 必选, 模板内容,格式形如 { "key1": "value1", "key2": "value2" },具体使用方式参考下文请求示例
	Page        string            `json:"page"`         // 可选, 跳转的页面
}

NotifyReq 订阅消息请求参数

type NotifyResp

type NotifyResp struct {
	ErrNo   int64  `json:"err_no"`
	ErrTips string `json:"err_tips"`
}

type SDK

type SDK struct {
	HttpCli        *http.Client
	AppID          string
	Secret         string
	RedisCli       redis.UniversalClient
	RedisSync      *redsync.Redsync
	TokenKey       string
	TokenLockerKey string
	IsSandBox      bool
	Logger         Logger
}

func (*SDK) CallToken

func (sdk *SDK) CallToken(ctx context.Context) (*TokenResp, error)

func (*SDK) DecodeTokenResp

func (sdk *SDK) DecodeTokenResp(result map[string]string) *TokenResp

func (*SDK) JsCode2Session

func (sdk *SDK) JsCode2Session(ctx context.Context, code string, anonymousCode string) (*JsCode2SessionResp, error)

func (*SDK) Notify

func (sdk *SDK) Notify(ctx context.Context, req *NotifyReq) (*NotifyResp, error)

Notify 发送订阅消息

func (*SDK) SaveTokenRespToRedis

func (sdk *SDK) SaveTokenRespToRedis(ctx context.Context, tokenResp *TokenResp) error

func (*SDK) Token

func (sdk *SDK) Token(ctx context.Context) (*TokenResp, error)

type TokenData

type TokenData struct {
	AccessToken string `json:"access_token"` // string 获取到的凭证
	ExpiresIn   int64  `json:"expires_in"`   // number	凭证有效时间,单位:秒
}

type TokenReq

type TokenReq struct {
	AppID     string `json:"appid"`
	Secret    string `json:"secret"`
	GrantType string `json:"grant_type"`
}

type TokenResp

type TokenResp struct {
	ErrNo   int64      `json:"err_no"`
	ErrTips string     `json:"err_tips"`
	Data    *TokenData `json:"data"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL