message

package
v0.0.0-...-cdf81b2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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"
)

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       string `xml:"Title,omitempty"`
	Description string `xml:"Description,omitempty"`
	PicURL      string `xml:"PicUrl,omitempty"`
	URL         string `xml:"Url,omitempty"`
}

Article 单篇文章

func NewArticle

func NewArticle(title, description, picURL, url string) *Article

NewArticle 初始化文章

type CommonToken

type CommonToken struct {
	XMLName      xml.Name `xml:"xml"json:"-"`
	ToUserName   string   `xml:"ToUserName"`
	FromUserName string   `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 string)

SetFromUserName set FromUserName

func (*CommonToken) SetMsgType

func (msg *CommonToken) SetMsgType(msgType MsgType)

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 事件类型

type Image

type Image struct {
	CommonToken

	Image struct {
		MediaID string `xml:"MediaId"`
	} `xml:"Image"`
}

Image 图片消息

func NewImage

func NewImage(mediaID string) *Image

NewImage 回复图片消息

type MixMessage

type MixMessage struct {
	CommonToken

	//基本消息
	MsgID        int64   `xml:"MsgId"json:"MsgID,omitempty"`
	Content      string  `xml:"Content"json:"Content,omitempty"`
	PicURL       string  `xml:"PicUrl"json:"PicURL,omitempty"`
	MediaID      string  `xml:"MediaId"json:"MediaId,omitempty"`
	Format       string  `xml:"Format"json:"Format,omitempty"`
	ThumbMediaID string  `xml:"ThumbMediaId"json:"ThumbMediaID,omitempty"`
	LocationX    float64 `xml:"Location_X"json:"LocationX,omitempty"`
	LocationY    float64 `xml:"Location_Y"json:"LocationY,omitempty"`
	Scale        float64 `xml:"Scale"json:"Scale,omitempty"`
	Label        string  `xml:"Label"json:"Label,omitempty"`
	Title        string  `xml:"Title"json:"Title,omitempty"`
	Description  string  `xml:"Description"json:"Description,omitempty"`
	URL          string  `xml:"Url"json:"URL,omitempty"`

	//事件相关
	Event     EventType `xml:"Event"json:"Event,omitempty"`
	EventKey  string    `xml:"EventKey"json:"EventKey,omitempty"`
	Ticket    string    `xml:"Ticket"json:"Ticket,omitempty"`
	Latitude  string    `xml:"Latitude"json:"Latitude,omitempty"`
	Longitude string    `xml:"Longitude"json:"Longitude,omitempty"`
	Precision string    `xml:"Precision"json:"Precision,omitempty"`
	MenuID    string    `xml:"MenuId"json:"MenuID,omitempty"`

	ScanCodeInfo struct {
		ScanType   string `xml:"ScanType"`
		ScanResult string `xml:"ScanResult"`
	} `xml:"ScanCodeInfo"json:"-"`

	SendPicsInfo struct {
		Count   int32      `xml:"Count"`
		PicList []EventPic `xml:"PicList>item"`
	} `xml:"SendPicsInfo"json:"-"`

	SendLocationInfo struct {
		LocationX float64 `xml:"Location_X"`
		LocationY float64 `xml:"Location_Y"`
		Scale     float64 `xml:"Scale"`
		Label     string  `xml:"Label"`
		Poiname   string  `xml:"Poiname"`
	} `xml:"SendLocationInfo"json:"-"`
}

MixMessage 存放所有微信发送过来的消息和事件

type MsgType

type MsgType string

MsgType 基本消息类型

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 音乐消息

func NewMusic

func NewMusic(title, description, musicURL, hQMusicURL, thumbMediaID string) *Music

NewMusic 回复音乐消息

type News

type News struct {
	CommonToken

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

News 图文消息

func NewNews

func NewNews(articles []*Article) *News

NewNews 初始化图文消息

type Reply

type Reply struct {
	MsgType MsgType
	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 string `xml:"Content" json:"Content"`
}

Text 文本消息

func NewText

func NewText(content string) *Text

NewText 初始化文本消息

type Video

type Video struct {
	CommonToken

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

Video 视频消息

func NewVideo

func NewVideo(mediaID, title, description string) *Video

NewVideo 回复图片消息

type Voice

type Voice struct {
	CommonToken

	Voice struct {
		MediaID string `xml:"MediaId"`
	} `xml:"Voice"`
}

Voice 语音消息

func NewVoice

func NewVoice(mediaID string) *Voice

NewVoice 回复语音消息

Jump to

Keyboard shortcuts

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