Documentation
¶
Overview ¶
被动接收的基本消息(事件)的数据结构定义, 更多的消息(事件)定义在对应的业务模块内.
Index ¶
Constants ¶
View Source
const ( // 普通事件类型 EventTypeSubscribe core.EventType = "subscribe" // 关注事件, 包括点击关注和扫描二维码(公众号二维码和公众号带参数二维码)关注 EventTypeUnsubscribe core.EventType = "unsubscribe" // 取消关注事件 EventTypeScan core.EventType = "SCAN" // 已经关注的用户扫描带参数二维码事件 EventTypeLocation core.EventType = "LOCATION" // 上报地理位置事件 )
View Source
const ( // 普通消息类型 MsgTypeText core.MsgType = "text" // 文本消息 MsgTypeImage core.MsgType = "image" // 图片消息 MsgTypeVoice core.MsgType = "voice" // 语音消息 MsgTypeVideo core.MsgType = "video" // 视频消息 MsgTypeShortVideo core.MsgType = "shortvideo" // 小视频消息 MsgTypeLocation core.MsgType = "location" // 地理位置消息 MsgTypeLink core.MsgType = "link" // 链接消息 MsgTypeMpPage core.MsgType = "miniprogrampage" //小程序卡片 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Image ¶
type Image struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id, 64位整型
MediaId string `xml:"MediaId" json:"MediaId"` // 图片消息媒体id, 可以调用多媒体文件下载接口拉取数据.
PicURL string `xml:"PicUrl" json:"PicUrl"` // 图片链接
}
图片消息
type Link ¶
type Link struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id, 64位整型
Title string `xml:"Title" json:"Title"` // 消息标题
Description string `xml:"Description" json:"Description"` // 消息描述
URL string `xml:"Url" json:"Url"` // 消息链接
}
链接消息
type Location ¶
type Location struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id, 64位整型
LocationX float64 `xml:"Location_X" json:"Location_X"` // 地理位置纬度
LocationY float64 `xml:"Location_Y" json:"Location_Y"` // 地理位置经度
Scale int `xml:"Scale" json:"Scale"` // 地图缩放大小
Label string `xml:"Label" json:"Label"` // 地理位置信息
}
地理位置消息
func GetLocation ¶
type LocationEvent ¶
type LocationEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // LOCATION
Latitude float64 `xml:"Latitude" json:"Latitude"` // 地理位置纬度
Longitude float64 `xml:"Longitude" json:"Longitude"` // 地理位置经度
Precision float64 `xml:"Precision" json:"Precision"` // 地理位置精度(整数? 但是微信推送过来是浮点数形式)
}
上报地理位置事件
func GetLocationEvent ¶
func GetLocationEvent(msg *core.MixedMsg) *LocationEvent
type MiniprogramPage ¶
type MiniprogramPage struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id, 64位整型
Title string `xml:"Title" json:"Title"` // 消息标题
AppId string `xml:"AppId" json:"AppId"`
PagePath string `xml:"PagePath" json:"PagePath"`
ThumbUrl string `xml:"ThumbUrl" json:"ThumbUrl"`
ThumbMediaId string `xml:"ThumbMediaId" json:"ThumbMediaId"` // request
}
func GetMiniprogramPage ¶
func GetMiniprogramPage(msg *core.MixedMsg) *MiniprogramPage
type ScanEvent ¶
type ScanEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // SCAN
EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值, 二维码的参数值(scene_id, scene_str)
Ticket string `xml:"Ticket" json:"Ticket"` // 二维码的ticket, 可用来换取二维码图片
}
用户已关注时, 扫描带参数二维码的事件
func GetScanEvent ¶
type ShortVideo ¶
type ShortVideo struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id, 64位整型
MediaId string `xml:"MediaId" json:"MediaId"` // 视频消息媒体id, 可以调用多媒体文件下载接口拉取数据.
ThumbMediaId string `xml:"ThumbMediaId" json:"ThumbMediaId"` // 视频消息缩略图的媒体id, 可以调用多媒体文件下载接口拉取数据.
}
小视频消息
func GetShortVideo ¶
func GetShortVideo(msg *core.MixedMsg) *ShortVideo
type SubscribeEvent ¶
type SubscribeEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // subscribe
// 下面两个字段只有在扫描带参数二维码进行关注时才有值, 否则为空值!
EventKey string `xml:"EventKey,omitempty" json:"EventKey,omitempty"` // 事件KEY值, 格式为: qrscene_二维码的参数值
Ticket string `xml:"Ticket,omitempty" json:"Ticket,omitempty"` // 二维码的ticket, 可用来换取二维码图片
}
关注事件
func GetSubscribeEvent ¶
func GetSubscribeEvent(msg *core.MixedMsg) *SubscribeEvent
func (*SubscribeEvent) Scene ¶
func (event *SubscribeEvent) Scene() (scene string, err error)
获取二维码参数
type Text ¶
type Text struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id, 64位整型
Content string `xml:"Content" json:"Content"` // 文本消息内容
BizMsgMenuId *int `xml:"bizmsgmenuid" json:"bizmsgmenuid"` //客服消息自定义菜单id
}
文本消息
func (Text) IsBizMsgMenu ¶
type UnsubscribeEvent ¶
type UnsubscribeEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
EventType core.EventType `xml:"Event" json:"Event"` // unsubscribe
EventKey string `xml:"EventKey,omitempty" json:"EventKey,omitempty"` // 事件KEY值, 空值
}
取消关注事件
func GetUnsubscribeEvent ¶
func GetUnsubscribeEvent(msg *core.MixedMsg) *UnsubscribeEvent
type Video ¶
type Video struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id, 64位整型
MediaId string `xml:"MediaId" json:"MediaId"` // 视频消息媒体id, 可以调用多媒体文件下载接口拉取数据.
ThumbMediaId string `xml:"ThumbMediaId" json:"ThumbMediaId"` // 视频消息缩略图的媒体id, 可以调用多媒体文件下载接口拉取数据.
}
视频消息
type Voice ¶
type Voice struct {
XMLName struct{} `xml:"xml" json:"-"`
core.MsgHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id, 64位整型
MediaId string `xml:"MediaId" json:"MediaId"` // 语音消息媒体id, 可以调用多媒体文件下载接口拉取该媒体
Format string `xml:"Format" json:"Format"` // 语音格式, 如amr, speex等
// 语音识别结果, UTF8编码,
// NOTE: 需要开通语音识别功能, 否则该字段为空, 即使开通了语音识别该字段还是有可能为空
Recognition string `xml:"Recognition,omitempty" json:"Recognition,omitempty"`
}
语音消息
Click to show internal directories.
Click to hide internal directories.