message

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventSubscribe 订阅
	EventSubscribe EventType = "subscribe"
	// EventUnsubscribe 取消订阅
	EventUnsubscribe = "unsubscribe"
	// EventScan 用户已经关注公众号,则微信会将带场景值扫描事件推送给开发者
	EventScan = "SCAN"
	// EventLocation 上报地理位置事件
	EventLocation = "LOCATION"
	// EventClick 点击菜单拉取消息时的事件推送
	EventClick = "CLICK"
	// EventView 点击菜单跳转链接时的事件推送
	EventView = "VIEW"
	// EventScancodePush 扫码推事件的事件推送
	EventScancodePush = "scancode_push"
	// EventScancodeWaitmsg 扫码推事件且弹出“消息接收中”提示框的事件推送
	EventScancodeWaitmsg = "scancode_waitmsg"
	// EventPicSysphoto 弹出系统拍照发图的事件推送
	EventPicSysphoto = "pic_sysphoto"
	// EventPicPhotoOrAlbum 弹出拍照或者相册发图的事件推送
	EventPicPhotoOrAlbum = "pic_photo_or_album"
	// EventPicWeixin 弹出微信相册发图器的事件推送
	EventPicWeixin = "pic_weixin"
	// EventLocationSelect 弹出地理位置选择器的事件推送
	EventLocationSelect = "location_select"
	// EventTemplateSendJobFinish 发送模板消息推送通知
	EventTemplateSendJobFinish = "TEMPLATESENDJOBFINISH"
	// EventMassSendJobFinish 群发消息推送通知
	EventMassSendJobFinish = "MASSSENDJOBFINISH"
	// EventWxaMediaCheck 异步校验图片/音频是否含有违法违规内容推送事件
	EventWxaMediaCheck = "wxa_media_check"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CDATA

type CDATA string

CDATA 使用该类型,在序列化为 xml 文本时文本会被解析器忽略

func (CDATA) MarshalXML

func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML 实现自己的序列化方法

type EncryptedXMLMsg

type EncryptedXMLMsg struct {
	XMLName      struct{} `xml:"xml" json:"-"`
	ToUserName   string   `xml:"ToUserName" json:"ToUserName"`
	EncryptedMsg string   `xml:"Encrypt"    json:"Encrypt"`
}

EncryptedXMLMsg 安全模式下的消息体

type EventType

type EventType string

EventType 事件类型

type MixMessage

type MixMessage struct {
	// 事件相关
	Event          EventType `xml:"Event"`
	ChangeType     string    `xml:"ChangeType"`
	UserID         string    `xml:"UserID"`
	Position       string    `xml:"Position"`
	Name           string    `xml:"Name"`
	Department     []int     `xml:"Department"`
	MainDepartment int       `xml:"MainDepartment"`
	IsLeaderInDept []int     `xml:"IsLeaderInDept"`
	Id             string    `xml:"Id"`
	ParentId       string    `xml:"ParentId"`
	Status         int       `xml:"Status"`
}

MixMessage 存放所有微信发送过来的消息和事件

func (*MixMessage) GetUserID

func (msg *MixMessage) GetUserID() string

GetOpenID get the FromUserName value

type PrivateSubscribeItem

type PrivateSubscribeItem struct {
	PriTmplID string `json:"priTmplId"` //	添加至帐号下的模板 id,发送订阅通知时所需
	Title     string `json:"title"`     // 模版标题
	Content   string `json:"content"`   // 模版内容
	Example   string `json:"example"`   // 模板内容示例
	SubType   int    `json:"type"`      // 模版类型,2 为一次性订阅,3 为长期订阅
}

PrivateSubscribeItem 私有订阅消息模板

type ResponseEncryptedXMLMsg

type ResponseEncryptedXMLMsg struct {
	XMLName      struct{} `xml:"xml" json:"-"`
	EncryptedMsg string   `xml:"Encrypt"      json:"Encrypt"`
	MsgSignature string   `xml:"MsgSignature" json:"MsgSignature"`
	Timestamp    int64    `xml:"TimeStamp"    json:"TimeStamp"`
	Nonce        string   `xml:"Nonce"        json:"Nonce"`
}

ResponseEncryptedXMLMsg 需要返回的消息体

type Subscribe

type Subscribe struct {
	*context.Context
}

Subscribe 订阅消息

func NewSubscribe

func NewSubscribe(context *context.Context) *Subscribe

NewSubscribe 实例化

func (*Subscribe) Add

func (tpl *Subscribe) Add(ShortID string, kidList []int, sceneDesc string) (templateID string, err error)

Add 添加订阅消息模板

func (*Subscribe) Delete

func (tpl *Subscribe) Delete(templateID string) (err error)

Delete 删除私有模板

func (*Subscribe) List

func (tpl *Subscribe) List() (templateList []*PrivateSubscribeItem, err error)

List 获取私有订阅消息模板列表

func (*Subscribe) Send

func (tpl *Subscribe) Send(msg *SubscribeMessage) (err error)

Send 发送订阅消息

type SubscribeDataItem

type SubscribeDataItem struct {
	Value string `json:"value"`
}

SubscribeDataItem 模版内某个 .DATA 的值

type SubscribeMessage

type SubscribeMessage struct {
	ToUser      string                        `json:"touser"`         // 必须, 接受者OpenID
	TemplateID  string                        `json:"template_id"`    // 必须, 模版ID
	Page        string                        `json:"page,omitempty"` // 可选, 跳转网页时填写
	Data        map[string]*SubscribeDataItem `json:"data"`           // 必须, 模板数据
	MiniProgram struct {
		AppID    string `json:"appid"`    // 所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系)
		PagePath string `json:"pagepath"` // 所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar)
	} `json:"miniprogram"` // 可选,跳转至小程序地址
}

SubscribeMessage 发送的订阅消息内容

type Template

type Template struct {
	*context.Context
}

Template 模板消息

func NewTemplate

func NewTemplate(context *context.Context) *Template

NewTemplate 实例化

func (*Template) Add

func (tpl *Template) Add(shortID string) (templateID string, err error)

Add 添加模板.

func (*Template) Delete

func (tpl *Template) Delete(templateID string) (err error)

Delete 删除私有模板.

func (*Template) List

func (tpl *Template) List() (templateList []*TemplateItem, err error)

List 获取模板列表

func (*Template) Send

func (tpl *Template) Send(msg *TemplateMessage) (msgID int64, err error)

Send 发送模板消息

type TemplateDataItem

type TemplateDataItem struct {
	Value string `json:"value"`
	Color string `json:"color,omitempty"`
}

TemplateDataItem 模版内某个 .DATA 的值

type TemplateItem

type TemplateItem struct {
	TemplateID      string `json:"template_id"`
	Title           string `json:"title"`
	PrimaryIndustry string `json:"primary_industry"`
	DeputyIndustry  string `json:"deputy_industry"`
	Content         string `json:"content"`
	Example         string `json:"example"`
}

TemplateItem 模板消息.

type TemplateMessage

type TemplateMessage struct {
	ToUser     string                       `json:"touser"`          // 必须, 接受者OpenID
	TemplateID string                       `json:"template_id"`     // 必须, 模版ID
	URL        string                       `json:"url,omitempty"`   // 可选, 用户点击后跳转的URL, 该URL必须处于开发者在公众平台网站中设置的域中
	Color      string                       `json:"color,omitempty"` // 可选, 整个消息的颜色, 可以不设置
	Data       map[string]*TemplateDataItem `json:"data"`            // 必须, 模板数据

	MiniProgram struct {
		AppID    string `json:"appid"`    // 所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系)
		PagePath string `json:"pagepath"` // 所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar)
	} `json:"miniprogram"` // 可选,跳转至小程序地址
}

TemplateMessage 发送的模板消息内容

Jump to

Keyboard shortcuts

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