Documentation
¶
Overview ¶
被动接收基本的消息(事件).
Index ¶
Constants ¶
View Source
const ( // 微信服务器推送过来的事件类型 EventTypeSubscribe = "subscribe" // 订阅, 包括点击订阅和扫描二维码 EventTypeUnsubscribe = "unsubscribe" // 取消订阅 EventTypeScan = "SCAN" // 已经订阅的用户扫描二维码事件 EventTypeLocation = "LOCATION" // 上报地理位置事件 )
View Source
const ( // 微信服务器推送过来的消息类型 MsgTypeText = "text" // 文本消息 MsgTypeImage = "image" // 图片消息 MsgTypeVoice = "voice" // 语音消息 MsgTypeVideo = "video" // 视频消息 MsgTypeLocation = "location" // 地理位置消息 MsgTypeLink = "link" // 链接消息 MsgTypeEvent = "event" // 事件推送 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Image ¶
type Image struct { XMLName struct{} `xml:"xml" json:"-"` mp.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 *mp.MixedMessage) *Image
type Link ¶
type Link struct { XMLName struct{} `xml:"xml" json:"-"` mp.CommonMessageHeader 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"` // 消息链接 }
链接消息
func GetLink ¶
func GetLink(msg *mp.MixedMessage) *Link
type Location ¶
type Location struct { XMLName struct{} `xml:"xml" json:"-"` mp.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 *mp.MixedMessage) *Location
type LocationEvent ¶
type LocationEvent struct { XMLName struct{} `xml:"xml" json:"-"` mp.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 *mp.MixedMessage) *LocationEvent
type ScanEvent ¶
type ScanEvent struct { XMLName struct{} `xml:"xml" json:"-"` mp.CommonMessageHeader Event string `xml:"Event" json:"Event"` // 事件类型,SCAN EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值,是一个32位无符号整数,即创建二维码时的二维码scene_id Ticket string `xml:"Ticket" json:"Ticket"` // 二维码的ticket,可用来换取二维码图片 }
用户已关注时,扫描带参数二维码的事件推送
func GetScanEvent ¶
func GetScanEvent(msg *mp.MixedMessage) *ScanEvent
type SubscribeByScanEvent ¶
type SubscribeByScanEvent struct { XMLName struct{} `xml:"xml" json:"-"` mp.CommonMessageHeader Event string `xml:"Event" json:"Event"` // 事件类型,subscribe EventKey string `xml:"EventKey" json:"EventKey"` // 事件KEY值,qrscene_为前缀,后面为二维码的参数值 Ticket string `xml:"Ticket" json:"Ticket"` // 二维码的ticket,可用来换取二维码图片 }
用户未关注时,扫描带参数二维码进行关注后的事件推送
func GetSubscribeByScanEvent ¶
func GetSubscribeByScanEvent(msg *mp.MixedMessage) *SubscribeByScanEvent
func (*SubscribeByScanEvent) Scene ¶
func (event *SubscribeByScanEvent) Scene() (scene string, err error)
获取二维码参数
type SubscribeEvent ¶
type SubscribeEvent struct { XMLName struct{} `xml:"xml" json:"-"` mp.CommonMessageHeader Event string `xml:"Event" json:"Event"` // 事件类型,subscribe(订阅) }
关注事件(普通关注)
func GetSubscribeEvent ¶
func GetSubscribeEvent(msg *mp.MixedMessage) *SubscribeEvent
type Text ¶
type Text struct { XMLName struct{} `xml:"xml" json:"-"` mp.CommonMessageHeader MsgId int64 `xml:"MsgId" json:"MsgId"` // 消息id, 64位整型 Content string `xml:"Content" json:"Content"` // 文本消息内容 }
文本消息
func GetText ¶
func GetText(msg *mp.MixedMessage) *Text
type UnsubscribeEvent ¶
type UnsubscribeEvent struct { XMLName struct{} `xml:"xml" json:"-"` mp.CommonMessageHeader Event string `xml:"Event" json:"Event"` // 事件类型,unsubscribe(取消订阅) }
取消关注
func GetUnsubscribeEvent ¶
func GetUnsubscribeEvent(msg *mp.MixedMessage) *UnsubscribeEvent
type Video ¶
type Video struct { XMLName struct{} `xml:"xml" json:"-"` mp.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 *mp.MixedMessage) *Video
type Voice ¶
type Voice struct { XMLName struct{} `xml:"xml" json:"-"` mp.CommonMessageHeader 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"` }
语音消息
func GetVoice ¶
func GetVoice(msg *mp.MixedMessage) *Voice
Click to show internal directories.
Click to hide internal directories.