Documentation
¶
Overview ¶
被动接收普通消息与事件.
Index ¶
Constants ¶
View Source
const ( // 微信服务器推送过来的事件类型 EventTypeSubscribe = "subscribe" // 订阅, 包括点击订阅和扫描二维码 EventTypeUnsubscribe = "unsubscribe" // 取消订阅 EventTypeLocation = "LOCATION" // 上报地理位置事件 )
View Source
const ( // 微信服务器推送过来的消息类型 MsgTypeText = "text" // 文本消息 MsgTypeImage = "image" // 图片消息 MsgTypeVoice = "voice" // 语音消息 MsgTypeVideo = "video" // 视频消息 MsgTypeLocation = "location" // 地理位置消息 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Image ¶
type Image struct {
XMLName struct{} `xml:"xml" json:"-"`
corp.CommonMessageHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id,64位整型
MediaId string `xml:"MediaId" json:"MediaId"` // 图片媒体文件id,可以调用获取媒体文件接口拉取数据
PicURL string `xml:"PicUrl" json:"PicUrl"` // 图片链接
}
func GetImage ¶
func GetImage(msg *corp.MixedMessage) *Image
type Location ¶
type Location struct {
XMLName struct{} `xml:"xml" json:"-"`
corp.CommonMessageHeader
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 ¶
func GetLocation(msg *corp.MixedMessage) *Location
type LocationEvent ¶
type LocationEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
corp.CommonMessageHeader
Event string `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 *corp.MixedMessage) *LocationEvent
type SubscribeEvent ¶
type SubscribeEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
corp.CommonMessageHeader
Event string `xml:"Event" json:"Event"` // 事件类型,subscribe(订阅)
}
关注事件
特别的,默认企业小助手可以用于获取整个企业号的关注状况。
func GetSubscribeEvent ¶
func GetSubscribeEvent(msg *corp.MixedMessage) *SubscribeEvent
type Text ¶
type Text struct {
XMLName struct{} `xml:"xml" json:"-"`
corp.CommonMessageHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id,64位整型
Content string `xml:"Content" json:"Content"` // 文本消息内容
}
func GetText ¶
func GetText(msg *corp.MixedMessage) *Text
type UnsubscribeEvent ¶
type UnsubscribeEvent struct {
XMLName struct{} `xml:"xml" json:"-"`
corp.CommonMessageHeader
Event string `xml:"Event" json:"Event"` // 事件类型,unsubscribe(取消订阅)
}
取消关注
func GetUnsubscribeEvent ¶
func GetUnsubscribeEvent(msg *corp.MixedMessage) *UnsubscribeEvent
type Video ¶
type Video struct {
XMLName struct{} `xml:"xml" json:"-"`
corp.CommonMessageHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id,64位整型
MediaId string `xml:"MediaId" json:"MediaId"` // 视频媒体文件id,可以调用获取媒体文件接口拉取数据
ThumbMediaId string `xml:"ThumbMediaId" json:"ThumbMediaId"` // 视频消息缩略图的媒体id,可以调用获取媒体文件接口拉取数据
}
func GetVideo ¶
func GetVideo(msg *corp.MixedMessage) *Video
type Voice ¶
type Voice struct {
XMLName struct{} `xml:"xml" json:"-"`
corp.CommonMessageHeader
MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id,64位整型
MediaId string `xml:"MediaId" json:"MediaId"` // 语音媒体文件id,可以调用获取媒体文件接口拉取数据
Format string `xml:"Format" json:"Format"` // 语音格式,如amr,speex等
}
func GetVoice ¶
func GetVoice(msg *corp.MixedMessage) *Voice
Click to show internal directories.
Click to hide internal directories.