wxoa

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMessageHandler

func RegisterMessageHandler(msgKind message.MessageKind, handler message.MessageHandler) error

Types

type JsSdkSignatureResult

type JsSdkSignatureResult struct {
	AppID     string `json:"appId"`
	Ticket    string `json:"ticket"`
	Noncestr  string `json:"noncestr"`
	Url       string `json:"Url"`
	Timestamp int64  `json:"timestamp"`
	Signature string `json:"signature"`
}

JsSdkSignatureResult signature接口返回结果

type Lib added in v0.0.4

type Lib interface {
	CreateJsSdkSignature(url string) (*JsSdkSignatureResult, error) // 生成jsapi_ticket签名
	VerifyServer(signature, token, timestamp, nonce string) bool    // 校验微信公众号服务器
	HandleMessage(data []byte) ([]byte, error)                      // 接收普通消息,接收事件消息以及被动回复消息
	SendTemplateMessage(toUser string, msg *TemplateMessage) error  // 发送模板消息

}

func New

func New(appId, appSecret string, redisProvider intf.RedisProvider) Lib

type TemplateMessage

type TemplateMessage struct {
	// 必要参数
	ToUser     string `json:"touser"`      // 发送给哪个openId
	TemplateId string `json:"template_id"` // 模板ID
	Data       any    `json:"data"`
	// 非必须的参数
	Url         string                      `json:"url"`           // 跳转链接
	MiniProgram *templateMessageMiniProgram `json:"miniprogram"`   // 跳小程序所需数据
	ClientMsgId string                      `json:"client_msg_id"` // 防重入id。对于同一个openid + client_msg_id, 只发送一条消息,10分钟有效,超过10分钟不保证效果。若无防重入需求,可不填
}

func NewTemplateMessage

func NewTemplateMessage(templateId string, contents map[string]string) *TemplateMessage

func (*TemplateMessage) LinkMiniProgram

func (m *TemplateMessage) LinkMiniProgram(appId, pagePath string) *TemplateMessage

LinkMiniProgram 链接小程序

func (*TemplateMessage) LinkUrl

func (m *TemplateMessage) LinkUrl(url string) *TemplateMessage

LinkUrl 链接外部URL

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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