wxminiprogram

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: MIT Imports: 15 Imported by: 0

README

wxminiprogram

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	URLAuth_Code2Session   = "https://api.weixin.qq.com/sns/jscode2session"
	URLAuth_GetAccessToken = "https://api.weixin.qq.com/cgi-bin/token"

	URLSubscribeMessage_Send = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send"
)

Functions

This section is empty.

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

func (*Auth) Code2Session

func (auth *Auth) Code2Session(ctx context.Context, code string) (*AuthCode2SessionResp, error)

func (*Auth) GetAccessToken

func (auth *Auth) GetAccessToken(ctx context.Context) (*AuthGetAccessTokenResp, error)

type AuthCode2SessionResp

type AuthCode2SessionResp struct {
	ErrCode    int64  `json:"errcode"`
	ErrMsg     string `json:"errmsg"`
	AppID      string
	OpenID     string `json:"openid"`      // 用户唯一标识
	SessionKey string `json:"session_key"` // 会话密钥
	UnionID    string `json:"unionid"`     // 用户在开放平台的唯一标识符,在满足UnionID下发条件的情况下会返回
}

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

type AuthGetAccessTokenResp

type AuthGetAccessTokenResp struct {
	ErrCode     int64  `json:"errcode"`
	ErrMsg      string `json:"errmsg"`
	AppID       string
	AccessToken string `json:"access_token"` // string 获取到的凭证
	ExpiresIn   int    `json:"expires_in"`   // number	凭证有效时间,单位:秒。目前是7200秒之内的值
}

type ErrorLogger

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

type Option

type Option func(o *options)

func AccessTokenKey

func AccessTokenKey(key string) Option

func AccessTokenLockerKey

func AccessTokenLockerKey(key string) Option

func AppID

func AppID(appid string) Option

func HttpClient

func HttpClient(httpCli *http.Client) Option

func Logger

func Logger(l ErrorLogger) Option

func RedisClient

func RedisClient(client redis.UniversalClient) Option

func Secret

func Secret(secret string) Option

type SDK

type SDK struct {
	// contains filtered or unexported fields
}

SDK 微信小程序SDK

func NewSDK

func NewSDK(opts ...Option) *SDK

func (*SDK) AppID

func (sdk *SDK) AppID() string

func (*SDK) Auth

func (sdk *SDK) Auth() *Auth

func (*SDK) SubscribeMessage

func (sdk *SDK) SubscribeMessage() *SubscribeMessage

type SubscribeMessage

type SubscribeMessage struct {
	// contains filtered or unexported fields
}

func (*SubscribeMessage) Send

func (sm *SubscribeMessage) Send(
	ctx context.Context, accessToken string, openID string, templateID string,
	page string, data string, miniProgramState string, lang string,
) (*SubscribeMessageSendResp, error)

Send 发送订阅消息 属性 默认值 access_token, 必填->是, 说明->接口调用凭证 openID, 必填->是, 说明->接收者(用户)的 openid template_id, 必填->是, 说明->所需下发的订阅模板id page, 必填->否, 说明->点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。 data, 必填->是, 说明->模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } } miniprogram_state, 必填->否, 说明->跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版 lang, 必填->否, 说明->进入小程序查看”的语言类型,支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN

type SubscribeMessageSendResp

type SubscribeMessageSendResp struct {
	ErrCode    int64  `json:"errcode"`
	ErrMsg     string `json:"errmsg"`
	AppID      string
	OpenID     string `json:"openid"`      // 用户唯一标识
	SessionKey string `json:"session_key"` // 会话密钥
	UnionID    string `json:"unionid"`     // 用户在开放平台的唯一标识符,在满足UnionID下发条件的情况下会返回
}

Jump to

Keyboard shortcuts

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