message

package
v0.0.0-...-79c8a7c Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgTypeText       = "text"                      //MsgTypeText 表示文本消息
	MsgTypeImage      = "image"                     //MsgTypeImage 表示图片消息
	MsgTypeVoice      = "voice"                     //MsgTypeVoice 表示语音消息
	MsgTypeVideo      = "video"                     //MsgTypeVideo 表示视频消息
	MsgTypeShortVideo = "shortvideo"                //MsgTypeShortVideo 表示短视频消息[限接收]
	MsgTypeLocation   = "location"                  //MsgTypeLocation 表示坐标消息[限接收]
	MsgTypeLink       = "link"                      //MsgTypeLink 表示链接消息[限接收]
	MsgTypeMusic      = "music"                     //MsgTypeMusic 表示音乐消息[限回复]
	MsgTypeNews       = "news"                      //MsgTypeNews 表示图文消息[限回复]
	MsgTypeTransfer   = "transfer_customer_service" //MsgTypeTransfer 表示消息消息转发到客服
	MsgTypeEvent      = "event"                     //MsgTypeEvent 表示事件推送消息
)

Variables

View Source
var ErrInvalidReply = errors.New("无效的回复消息")

ErrInvalidReply 无效的回复

View Source
var ErrUnsupportReply = errors.New("不支持的回复消息")

ErrUnsupportReply 不支持的回复类型

Functions

This section is empty.

Types

type Article

type Article struct {
	Title       CDATA `xml:"Title" json:"Title"`
	Description CDATA `xml:"Description" json:"Description"`
	PicURL      CDATA `xml:"PicUrl" json:"PicUrl"`
	URL         CDATA `xml:"Url" json:"Url"`
}

Article 单篇文章 都是必传参数

type BaseMessage

type BaseMessage struct {
	ToUserName   string  `xml:"ToUserName" json:"ToUserName"`
	FromUserName string  `xml:"FromUserName" json:"FromUserName"`
	CreateTime   int64   `xml:"CreateTime" json:"CreateTime"`
	MsgType      MsgType `xml:"MsgType" json:"MsgType"`
	Event        string  `xml:"Event" json:"Event"`
}

func (*BaseMessage) GetId

func (m *BaseMessage) GetId() string

type CDATA

type CDATA struct {
	Value string `xml:",cdata"`
}

type CommonToken

type CommonToken struct {
	XMLName      xml.Name `xml:"xml"`
	ToUserName   CDATA    `xml:"ToUserName"`
	FromUserName CDATA    `xml:"FromUserName"`
	CreateTime   int64    `xml:"CreateTime"`
	MsgType      CDATA    `xml:"MsgType"`
}

CommonToken 消息中通用的结构

func (*CommonToken) SetCreateTime

func (msg *CommonToken) SetCreateTime(createTime int64)

SetCreateTime set createTime

func (*CommonToken) SetFromUserName

func (msg *CommonToken) SetFromUserName(fromUserName string)

SetFromUserName set FromUserName

func (*CommonToken) SetMsgType

func (msg *CommonToken) SetMsgType(msgType string)

SetMsgType set MsgType

func (*CommonToken) SetToUserName

func (msg *CommonToken) SetToUserName(toUserName string)

SetToUserName set ToUserName

type EncryptedXMLMsg

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

EncryptedXMLMsg 安全模式下的消息体

type EventPic

type EventPic struct {
	PicMd5Sum string `xml:"PicMd5Sum"`
}

EventPic 发图事件推送

type EventType

type EventType string

EventType 事件类型

const (
	EventSubscribe                EventType = "subscribe"               //EventSubscribe 订阅
	EventUnsubscribe              EventType = "unsubscribe"             //EventUnsubscribe 取消订阅
	EventScan                     EventType = "SCAN"                    //EventScan 用户已经关注公众号,则微信会将带场景值扫描事件推送给开发者
	EventLocation                 EventType = "LOCATION"                //EventLocation 上报地理位置事件
	EventClick                    EventType = "CLICK"                   //EventClick 点击菜单拉取消息时的事件推送
	EventView                     EventType = "VIEW"                    //EventView 点击菜单跳转链接时的事件推送
	EventScancodePush             EventType = "scancode_push"           //EventScancodePush 扫码推事件的事件推送
	EventScancodeWaitmsg          EventType = "scancode_waitmsg"        //EventScancodeWaitmsg 扫码推事件且弹出“消息接收中”提示框的事件推送
	EventPicSysphoto              EventType = "pic_sysphoto"            //EventPicSysphoto 弹出系统拍照发图的事件推送
	EventPicPhotoOrAlbum          EventType = "pic_photo_or_album"      //EventPicPhotoOrAlbum 弹出拍照或者相册发图的事件推送
	EventPicWeixin                EventType = "pic_weixin"              //EventPicWeixin 弹出微信相册发图器的事件推送
	EventLocationSelect           EventType = "location_select"         //EventLocationSelect 弹出地理位置选择器的事件推送
	EventTemplateSendJobFinish    EventType = "TEMPLATESENDJOBFINISH"   //EventTemplateSendJobFinish 发送模板消息推送通知
	EventGiftcardPayDone          EventType = "giftcard_pay_done"       //用户购买礼品卡付款成功
	EventGiftcardSendToFriend     EventType = "giftcard_send_to_friend" //用户购买后赠送
	EventGiftcardSendUserAccept   EventType = "giftcard_user_accept"    //用户领取礼品卡成功
	EventUserGetCard              EventType = "user_get_card"           //领取
	EventUserGiftingCard          EventType = "user_gifting_card"       //转赠
	EventUserAuthorizeInvoice     EventType = "user_authorize_invoice"  //接收开票事件
	EventCardPassCheck            EventType = "card_pass_check"         //审核事件推送
	EventNotCardPassCheck         EventType = "card_not_pass_check"
	EventAddStoreAuditInfo        EventType = "add_store_audit_info"
	EventCreateMapPoiAuditInfo    EventType = "create_map_poi_audit_info"
	EventKfCreateSession          EventType = "kf_create_session"
	EventKfCloseSession           EventType = "kf_close_session"
	EventSubmitMembercardUserInfo EventType = "submit_membercard_user_info"
	EventUserConsumeCard          EventType = "user_consume_card"
	EventUserDelCard              EventType = "user_del_card"
	EventUserViewCard             EventType = "user_view_card"
	EventViewMiniprogram          EventType = "view_miniprogram"
)

type Image

type Image struct {
	CommonToken

	Image struct {
		MediaID CDATA `xml:"MediaId" json:"MediaId"`
	} `xml:"Image"`
}

Image 图片消息

func NewImage

func NewImage(MpImage *MpImage) *Image

NewImage 回复图片消息

func NewImageByJson

func NewImageByJson(js string) (*Image, error)

type MpArticle

type MpArticle struct {
	Title       string `xml:"Title" json:"Title"`
	Description string `xml:"Description" json:"Description"`
	PicURL      string `xml:"PicUrl" json:"PicUrl"`
	URL         string `xml:"Url" json:"Url"`
}

type MpImage

type MpImage struct {
	MediaID string `xml:"MediaId" json:"MediaId"`
}

type MpMusic

type MpMusic struct {
	Title        string `xml:"Title"        json:"Title"`
	Description  string `xml:"Description"  json:"Description"`
	MusicURL     string `xml:"MusicUrl"     json:"MusicUrl"`
	HQMusicURL   string `xml:"HQMusicUrl"   json:"HQMusicUrl"`
	ThumbMediaID string `xml:"ThumbMediaId" json:"ThumbMediaId"`
}

type MpText

type MpText struct {
	Content string `json:"Content"`
}

type MpVideo

type MpVideo struct {
	MediaID     string `xml:"MediaId" json:"MediaId"`
	Title       string `xml:"Title,omitempty" json:"Title,omitempty"`
	Description string `xml:"Description,omitempty" json:"Description,omitempty"`
}

type MpVoice

type MpVoice struct {
	MediaID string `xml:"MediaId" json:"MediaId"`
}

type MsgType

type MsgType string

MsgType 基本消息类型

type Music

type Music struct {
	CommonToken

	Music struct {
		Title        CDATA `xml:"Title"        json:"Title"`
		Description  CDATA `xml:"Description"  json:"Description"`
		MusicURL     CDATA `xml:"MusicUrl"     json:"MusicUrl"`
		HQMusicURL   CDATA `xml:"HQMusicUrl"   json:"HQMusicUrl"`
		ThumbMediaID CDATA `xml:"ThumbMediaId" json:"ThumbMediaId"`
	} `xml:"Music"`
}

Music 音乐消息

func NewMusic

func NewMusic(MpMusic *MpMusic) *Music

NewMusic 回复音乐消息

func NewMusicByJson

func NewMusicByJson(js string) (*Music, error)

type News

type News struct {
	CommonToken

	ArticleCount int        `xml:"ArticleCount"`
	Articles     []*Article `xml:"Articles>item,omitempty"`
}

News 图文消息

func NewNews

func NewNews(MpArticle []*MpArticle) *News

NewNews 初始化图文消息

func NewNewsByJson

func NewNewsByJson(js string) (*News, error)

type Reply

type Reply struct {
	MsgType string
	MsgData interface{}
}

Reply 消息回复

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 Text

type Text struct {
	CommonToken
	Content CDATA `xml:"Content" json:"Content"`
}

Text 文本消息

func NewText

func NewText(MpText *MpText) *Text

NewText 初始化文本消息

func NewTextByJson

func NewTextByJson(jsContent string) (*Text, error)

传入json格式 返回固定的微信格式

type TransInfo

type TransInfo struct {
	KfAccount string `xml:"KfAccount"`
}

TransInfo 转发到指定客服

type TransferCustomer

type TransferCustomer struct {
	CommonToken

	TransInfo *TransInfo `xml:"TransInfo,omitempty"`
}

TransferCustomer 转发客服消息

func NewTransferCustomer

func NewTransferCustomer(KfAccount string) *TransferCustomer

NewTransferCustomer 实例化

type Video

type Video struct {
	CommonToken

	Video struct {
		MediaID     CDATA `xml:"MediaId"`
		Title       CDATA `xml:"Title,omitempty"`
		Description CDATA `xml:"Description,omitempty"`
	} `xml:"Video"`
}

Video 视频消息

func NewVideo

func NewVideo(MpVideo *MpVideo) *Video

NewVideo 回复图片消息

func NewVideoByJson

func NewVideoByJson(js string) (*Video, error)

数据库目前没有保存Title和 Description

type Voice

type Voice struct {
	CommonToken

	Voice struct {
		MediaID CDATA `xml:"MediaId" json:"MediaId"`
	} `xml:"Voice"`
}

Voice 语音消息

func NewVoice

func NewVoice(MpVoice *MpVoice) *Voice

NewVoice 回复语音消息

func NewVoiceByJson

func NewVoiceByJson(js string) (*Voice, error)

Jump to

Keyboard shortcuts

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