Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterMessageHandler ¶
func RegisterMessageHandler(msgKind message2.MessageKind, handler message2.MessageHandler) error
Types ¶
type API ¶
type API interface {
CreateJsSdkSignature(url string) (*JsSdkSignatureResult, error) // 生成jsapi_ticket签名
VerifyServer(token string, queryParams map[string]string) (string, error) // 校验微信公众号服务器
HandleMessage(data []byte) ([]byte, error) // 接收普通消息,接收事件消息以及被动回复消息
SendTemplateMessage(toUser string, msg *TemplateMessage) error // 发送模板消息
}
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 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
Source Files
¶
Click to show internal directories.
Click to hide internal directories.