Documentation
¶
Index ¶
- Constants
- Variables
- type Article
- type CDATA
- type CommonToken
- type CustomerMessage
- type EncryptedXMLMsg
- type EventPic
- type EventType
- type Image
- type InfoType
- type Manager
- type MediaArticles
- type MediaMiniprogrampage
- type MediaMsgmenu
- type MediaMusic
- type MediaNews
- type MediaResource
- type MediaText
- type MediaVideo
- type MediaWxcard
- type MixMessage
- type MsgType
- type MsgmenuItem
- type Music
- type News
- type Reply
- type ResponseEncryptedXMLMsg
- type Text
- type TransInfo
- type TransferCustomer
- type Video
- type Voice
Constants ¶
const ( //MsgTypeText 表示文本消息 MsgTypeText MsgType = "text" //MsgTypeImage 表示图片消息 MsgTypeImage = "image" //MsgTypeVoice 表示语音消息 MsgTypeVoice = "voice" //MsgTypeVideo 表示视频消息 MsgTypeVideo = "video" //MsgTypeShortVideo 表示短视频消息[限接收] MsgTypeShortVideo = "shortvideo" //MsgTypeLocation 表示坐标消息[限接收] MsgTypeLocation = "location" //MsgTypeLink 表示链接消息[限接收] MsgTypeLink = "link" //MsgTypeMusic 表示音乐消息[限回复] MsgTypeMusic = "music" //MsgTypeNews 表示图文消息[限回复] MsgTypeNews = "news" //MsgTypeTransfer 表示消息消息转发到客服 MsgTypeTransfer = "transfer_customer_service" //MsgTypeEvent 表示事件推送消息 MsgTypeEvent = "event" )
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" //EventWxaMediaCheck 异步校验图片/音频是否含有违法违规内容推送事件 EventWxaMediaCheck = "wxa_media_check" )
const ( // InfoTypeVerifyTicket 返回ticket InfoTypeVerifyTicket InfoType = "component_verify_ticket" // InfoTypeAuthorized 授权 InfoTypeAuthorized = "authorized" InfoTypeUnauthorized = "unauthorized" // InfoTypeUpdateAuthorized 更新授权 InfoTypeUpdateAuthorized = "updateauthorized" )
Variables ¶
var ErrInvalidReply = errors.New("无效的回复消息")
ErrInvalidReply 无效的回复
var ErrUnsupportReply = errors.New("不支持的回复消息")
ErrUnsupportReply 不支持的回复类型
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct {
Title string `xml:"Title,omitempty"`
Description string `xml:"Description,omitempty"`
PicURL string `xml:"PicUrl,omitempty"`
URL string `xml:"Url,omitempty"`
}
Article 单篇文章
type CDATA ¶ added in v1.2.1
type CDATA string
CDATA 使用该类型,在序列化为 xml 文本时文本会被解析器忽略
func (CDATA) MarshalXML ¶ added in v1.2.1
MarshalXML 实现自己的序列化方法
type CommonToken ¶
type CommonToken struct {
XMLName xml.Name `xml:"xml"`
ToUserName CDATA `xml:"ToUserName"`
FromUserName CDATA `xml:"FromUserName"`
CreateTime int64 `xml:"CreateTime"`
MsgType MsgType `xml:"MsgType"`
}
CommonToken 消息中通用的结构
func (*CommonToken) SetCreateTime ¶
func (msg *CommonToken) SetCreateTime(createTime int64)
SetCreateTime set createTime
func (*CommonToken) SetFromUserName ¶
func (msg *CommonToken) SetFromUserName(fromUserName CDATA)
SetFromUserName set FromUserName
func (*CommonToken) SetMsgType ¶
func (msg *CommonToken) SetMsgType(msgType MsgType)
SetMsgType set MsgType
func (*CommonToken) SetToUserName ¶
func (msg *CommonToken) SetToUserName(toUserName CDATA)
SetToUserName set ToUserName
type CustomerMessage ¶ added in v1.2.1
type CustomerMessage struct {
ToUser string `json:"touser"` //接受者OpenID
Msgtype MsgType `json:"msgtype"` //客服消息类型
Text *MediaText `json:"text,omitempty"` //可选
Image *MediaResource `json:"image,omitempty"` //可选
Voice *MediaResource `json:"voice,omitempty"` //可选
Video *MediaVideo `json:"video,omitempty"` //可选
Music *MediaMusic `json:"music,omitempty"` //可选
News *MediaNews `json:"news,omitempty"` //可选
Mpnews *MediaResource `json:"mpnews,omitempty"` //可选
Wxcard *MediaWxcard `json:"wxcard,omitempty"` //可选
Miniprogrampage *MediaMiniprogrampage `json:"miniprogrampage,omitempty"` //可选
}
CustomerMessage 客服消息
func NewCustomerImgMessage ¶ added in v1.2.1
func NewCustomerImgMessage(toUser, mediaID string) *CustomerMessage
NewCustomerImgMessage 图片消息的构造方法
func NewCustomerTextMessage ¶ added in v1.2.1
func NewCustomerTextMessage(toUser, text string) *CustomerMessage
NewCustomerTextMessage 文本消息结构体构造方法
func NewCustomerVoiceMessage ¶ added in v1.2.1
func NewCustomerVoiceMessage(toUser, mediaID string) *CustomerMessage
NewCustomerVoiceMessage 语音消息的构造方法
type EncryptedXMLMsg ¶
type EncryptedXMLMsg struct {
XMLName struct{} `xml:"xml" json:"-"`
ToUserName string `xml:"ToUserName" json:"ToUserName"`
EncryptedMsg string `xml:"Encrypt" json:"Encrypt"`
}
EncryptedXMLMsg 安全模式下的消息体
type Image ¶
type Image struct {
CommonToken
Image struct {
MediaID string `xml:"MediaId"`
} `xml:"Image"`
}
Image 图片消息
type Manager ¶ added in v1.2.1
Manager 消息管理者,可以发送消息
func NewMessageManager ¶ added in v1.2.1
NewMessageManager 实例化消息管理者
func (*Manager) Send ¶ added in v1.2.1
func (manager *Manager) Send(msg *CustomerMessage) error
Send 发送客服消息
type MediaArticles ¶ added in v1.2.1
type MediaArticles struct {
Title string `json:"title"`
Description string `json:"description"`
URL string `json:"url"`
Picurl string `json:"picurl"`
}
MediaArticles 图文消息的内容的文章列表中的单独一条
type MediaMiniprogrampage ¶ added in v1.2.1
type MediaMiniprogrampage struct {
Title string `json:"title"`
Appid string `json:"appid"`
Pagepath string `json:"pagepath"`
ThumbMediaID string `json:"thumb_media_id"`
}
MediaMiniprogrampage 小程序消息
type MediaMusic ¶ added in v1.2.1
type MediaMusic struct {
Title string `json:"title"`
Description string `json:"description"`
Musicurl string `json:"musicurl"`
Hqmusicurl string `json:"hqmusicurl"`
ThumbMediaID string `json:"thumb_media_id"`
}
MediaMusic 音乐消息包括的内容
type MediaNews ¶ added in v1.2.1
type MediaNews struct {
Articles []MediaArticles `json:"articles"`
}
MediaNews 图文消息的内容
type MediaResource ¶ added in v1.2.1
type MediaResource struct {
MediaID string `json:"media_id"`
}
MediaResource 消息使用的永久素材id
type MediaText ¶ added in v1.2.1
type MediaText struct {
Content string `json:"content"`
}
MediaText 文本消息的文字
type MediaVideo ¶ added in v1.2.1
type MediaVideo struct {
MediaID string `json:"media_id"`
ThumbMediaID string `json:"thumb_media_id"`
Title string `json:"title"`
Description string `json:"description"`
}
MediaVideo 视频消息包含的内容
type MediaWxcard ¶ added in v1.2.1
type MediaWxcard struct {
CardID string `json:"card_id"`
}
MediaWxcard 卡券的id
type MixMessage ¶
type MixMessage struct {
CommonToken
//基本消息
MsgID int64 `xml:"MsgId"`
Content string `xml:"Content"`
Recognition string `xml:"Recognition"`
PicURL string `xml:"PicUrl"`
MediaID string `xml:"MediaId"`
Format string `xml:"Format"`
ThumbMediaID string `xml:"ThumbMediaId"`
LocationX float64 `xml:"Location_X"`
LocationY float64 `xml:"Location_Y"`
Scale float64 `xml:"Scale"`
Label string `xml:"Label"`
Title string `xml:"Title"`
Description string `xml:"Description"`
URL string `xml:"Url"`
//事件相关
Event EventType `xml:"Event"`
EventKey string `xml:"EventKey"`
Ticket string `xml:"Ticket"`
Latitude string `xml:"Latitude"`
Longitude string `xml:"Longitude"`
Precision string `xml:"Precision"`
MenuID string `xml:"MenuId"`
Status string `xml:"Status"`
SessionFrom string `xml:"SessionFrom"`
ScanCodeInfo struct {
ScanType string `xml:"ScanType"`
ScanResult string `xml:"ScanResult"`
} `xml:"ScanCodeInfo"`
SendPicsInfo struct {
Count int32 `xml:"Count"`
PicList []EventPic `xml:"PicList>item"`
} `xml:"SendPicsInfo"`
SendLocationInfo struct {
LocationX float64 `xml:"Location_X"`
LocationY float64 `xml:"Location_Y"`
Scale float64 `xml:"Scale"`
Label string `xml:"Label"`
Poiname string `xml:"Poiname"`
}
// 第三方平台相关
InfoType InfoType `xml:"InfoType"`
AppID string `xml:"AppId"`
ComponentVerifyTicket string `xml:"ComponentVerifyTicket"`
AuthorizerAppid string `xml:"AuthorizerAppid"`
AuthorizationCode string `xml:"AuthorizationCode"`
AuthorizationCodeExpiredTime int64 `xml:"AuthorizationCodeExpiredTime"`
PreAuthCode string `xml:"PreAuthCode"`
// 卡券相关
CardID string `xml:"CardId"`
RefuseReason string `xml:"RefuseReason"`
IsGiveByFriend int32 `xml:"IsGiveByFriend"`
FriendUserName string `xml:"FriendUserName"`
UserCardCode string `xml:"UserCardCode"`
OldUserCardCode string `xml:"OldUserCardCode"`
OuterStr string `xml:"OuterStr"`
IsRestoreMemberCard int32 `xml:"IsRestoreMemberCard"`
UnionID string `xml:"UnionId"`
// 内容审核相关
IsRisky bool `xml:"isrisky"`
ExtraInfoJSON string `xml:"extra_info_json"`
TraceID string `xml:"trace_id"`
StatusCode int `xml:"status_code"`
//设备相关
device.MsgDevice
}
MixMessage 存放所有微信发送过来的消息和事件
type Music ¶
type Music struct {
CommonToken
Music struct {
Title string `xml:"Title" `
Description string `xml:"Description" `
MusicURL string `xml:"MusicUrl" `
HQMusicURL string `xml:"HQMusicUrl" `
ThumbMediaID string `xml:"ThumbMediaId"`
} `xml:"Music"`
}
Music 音乐消息
type News ¶
type News struct {
CommonToken
ArticleCount int `xml:"ArticleCount"`
Articles []*Article `xml:"Articles>item,omitempty"`
}
News 图文消息
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 TransferCustomer ¶
type TransferCustomer struct {
CommonToken
TransInfo *TransInfo `xml:"TransInfo,omitempty"`
}
TransferCustomer 转发客服消息
func NewTransferCustomer ¶
func NewTransferCustomer(KfAccount string) *TransferCustomer
NewTransferCustomer 实例化