message

package
v2.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0 Imports: 8 Imported by: 54

Documentation

Index

Constants

This section is empty.

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 CDATA

type CDATA string

CDATA 使用该类型,在序列化为 xml 文本时文本会被解析器忽略

func (CDATA) MarshalXML

func (c CDATA) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML 实现自己的序列化方法

type CommonToken

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

CommonToken 消息中通用的结构

func (*CommonToken) GetOpenID added in v2.0.5

func (msg *CommonToken) GetOpenID() string

GetOpenID get the FromUserName value

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

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"`          // 可选
	Msgmenu         *MediaMsgmenu         `json:"msgmenu,omitempty"`         // 可选
	Miniprogrampage *MediaMiniprogrampage `json:"miniprogrampage,omitempty"` // 可选
}

CustomerMessage 客服消息

func NewCustomerImgMessage

func NewCustomerImgMessage(toUser, mediaID string) *CustomerMessage

NewCustomerImgMessage 图片消息的构造方法

func NewCustomerMiniprogrampageMessage added in v2.0.3

func NewCustomerMiniprogrampageMessage(toUser, title, appID, pagePath, thumbMediaID string) *CustomerMessage

NewCustomerMiniprogrampageMessage 小程序卡片消息的构造方法

func NewCustomerTextMessage

func NewCustomerTextMessage(toUser, text string) *CustomerMessage

NewCustomerTextMessage 文本消息结构体构造方法

func NewCustomerVoiceMessage

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 EventPic

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

EventPic 发图事件推送

type EventType

type EventType string

EventType 事件类型

const (
	// EventSubscribe 订阅
	EventSubscribe EventType = "subscribe"
	// EventUnsubscribe 取消订阅
	EventUnsubscribe EventType = "unsubscribe"
	// EventScan 用户已经关注公众号,则微信会将带场景值扫描事件推送给开发者
	EventScan EventType = "SCAN"
	// EventLocation 上报地理位置事件
	EventLocation EventType = "LOCATION"
	// EventClick 点击菜单拉取消息时的事件推送
	EventClick EventType = "CLICK"
	// EventView 点击菜单跳转链接时的事件推送
	EventView EventType = "VIEW"
	// EventScancodePush 扫码推事件的事件推送
	EventScancodePush EventType = "scancode_push"
	// EventScancodeWaitmsg 扫码推事件且弹出“消息接收中”提示框的事件推送
	EventScancodeWaitmsg EventType = "scancode_waitmsg"
	// EventPicSysphoto 弹出系统拍照发图的事件推送
	EventPicSysphoto EventType = "pic_sysphoto"
	// EventPicPhotoOrAlbum 弹出拍照或者相册发图的事件推送
	EventPicPhotoOrAlbum EventType = "pic_photo_or_album"
	// EventPicWeixin 弹出微信相册发图器的事件推送
	EventPicWeixin EventType = "pic_weixin"
	// EventLocationSelect 弹出地理位置选择器的事件推送
	EventLocationSelect EventType = "location_select"
	// EventViewMiniprogram 点击菜单跳转小程序的事件推送
	EventViewMiniprogram EventType = "view_miniprogram"
	// EventTemplateSendJobFinish 发送模板消息推送通知
	EventTemplateSendJobFinish EventType = "TEMPLATESENDJOBFINISH"
	// EventMassSendJobFinish 群发消息推送通知
	EventMassSendJobFinish EventType = "MASSSENDJOBFINISH"
	// EventWxaMediaCheck 异步校验图片/音频是否含有违法违规内容推送事件
	EventWxaMediaCheck EventType = "wxa_media_check"
	// EventSubscribeMsgPopupEvent 订阅通知事件推送
	EventSubscribeMsgPopupEvent EventType = "subscribe_msg_popup_event"
	// EventPublishJobFinish 发布任务完成
	EventPublishJobFinish EventType = "PUBLISHJOBFINISH"
)

type Image

type Image struct {
	CommonToken

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

Image 图片消息

func NewImage

func NewImage(mediaID string) *Image

NewImage 回复图片消息

type InfoType

type InfoType string

InfoType 第三方平台授权事件类型

const (

	// InfoTypeVerifyTicket 返回ticket
	InfoTypeVerifyTicket InfoType = "component_verify_ticket"
	// InfoTypeAuthorized 授权
	InfoTypeAuthorized InfoType = "authorized"
	// InfoTypeUnauthorized 取消授权
	InfoTypeUnauthorized InfoType = "unauthorized"
	// InfoTypeUpdateAuthorized 更新授权
	InfoTypeUpdateAuthorized InfoType = "updateauthorized"
	// InfoTypeNotifyThirdFasterRegister 注册审核事件推送
	InfoTypeNotifyThirdFasterRegister InfoType = "notify_third_fasteregister"
)

type Manager

type Manager struct {
	*context.Context
}

Manager 消息管理者,可以发送消息

func NewMessageManager

func NewMessageManager(context *context.Context) *Manager

NewMessageManager 实例化消息管理者

func (*Manager) Send

func (manager *Manager) Send(msg *CustomerMessage) error

Send 发送客服消息

type MediaArticles

type MediaArticles struct {
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	Picurl      string `json:"picurl"`
}

MediaArticles 图文消息的内容的文章列表中的单独一条

type MediaMiniprogrampage

type MediaMiniprogrampage struct {
	Title        string `json:"title"`
	AppID        string `json:"appid"`
	Pagepath     string `json:"pagepath"`
	ThumbMediaID string `json:"thumb_media_id"`
}

MediaMiniprogrampage 小程序消息

type MediaMsgmenu

type MediaMsgmenu struct {
	HeadContent string        `json:"head_content"`
	List        []MsgmenuItem `json:"list"`
	TailContent string        `json:"tail_content"`
}

MediaMsgmenu 菜单消息的内容

type MediaMusic

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

type MediaNews struct {
	Articles []MediaArticles `json:"articles"`
}

MediaNews 图文消息的内容

type MediaResource

type MediaResource struct {
	MediaID string `json:"media_id"`
}

MediaResource 消息使用的永久素材id

type MediaText

type MediaText struct {
	Content string `json:"content"`
}

MediaText 文本消息的文字

type MediaVideo

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

type MediaWxcard struct {
	CardID string `json:"card_id"`
}

MediaWxcard 卡券的id

type MixMessage

type MixMessage struct {
	CommonToken

	// 基本消息
	MsgID         int64   `xml:"MsgId"` // 其他消息推送过来是MsgId
	TemplateMsgID int64   `xml:"MsgID"` // 模板消息推送成功的消息是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" json:"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"`
	TotalCount  int64     `xml:"TotalCount"`
	FilterCount int64     `xml:"FilterCount"`
	SentCount   int64     `xml:"SentCount"`
	ErrorCount  int64     `xml:"ErrorCount"`

	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"`
	}

	SubscribeMsgPopupEvent []struct {
		List SubscribeMsgPopupEvent `xml:"List"`
	} `xml:"SubscribeMsgPopupEvent"`

	// 事件相关:发布能力
	PublishEventInfo struct {
		PublishID     int64                     `xml:"publish_id"`     // 发布任务id
		PublishStatus freepublish.PublishStatus `xml:"publish_status"` // 发布状态
		ArticleID     string                    `xml:"article_id"`     // 当发布状态为0时(即成功)时,返回图文的 article_id,可用于“客服消息”场景
		ArticleDetail struct {
			Count uint `xml:"count"` // 文章数量
			Item  []struct {
				Index      uint   `xml:"idx"`         // 文章对应的编号
				ArticleURL string `xml:"article_url"` // 图文的永久链接
			} `xml:"item"`
		} `xml:"article_detail"` // 当发布状态为0时(即成功)时,返回内容
		FailIndex []uint `xml:"fail_idx"` // 当发布状态为2或4时,返回不通过的文章编号,第一篇为 1;其他发布状态则为空
	} `xml:"PublishEventInfo"`

	// 第三方平台相关
	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"`
	AuthCode                     string   `xml:"auth_code"`
	Info                         struct {
		Name               string `xml:"name"`
		Code               string `xml:"code"`
		CodeType           int    `xml:"code_type"`
		LegalPersonaWechat string `xml:"legal_persona_wechat"`
		LegalPersonaName   string `xml:"legal_persona_name"`
		ComponentPhone     string `xml:"component_phone"`
	} `xml:"info"`

	// 卡券相关
	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
	// contains filtered or unexported fields
}

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

func (*MixMessage) GetSubscribeMsgPopupEvents added in v2.1.3

func (s *MixMessage) GetSubscribeMsgPopupEvents() []SubscribeMsgPopupEvent

GetSubscribeMsgPopupEvents 获取订阅消息事件数据

func (*MixMessage) SetSubscribeMsgPopupEvents added in v2.1.3

func (s *MixMessage) SetSubscribeMsgPopupEvents(list []SubscribeMsgPopupEvent)

SetSubscribeMsgPopupEvents 设置订阅消息事件

type MsgType

type MsgType string

MsgType 基本消息类型

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

type MsgmenuItem

type MsgmenuItem struct {
	ID      string `json:"id"`
	Content string `json:"content"`
}

MsgmenuItem 菜单消息的菜单按钮

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 PrivateSubscribeItem added in v2.0.7

type PrivateSubscribeItem struct {
	PriTmplID string `json:"priTmplId"` //	添加至帐号下的模板 id,发送订阅通知时所需
	Title     string `json:"title"`     // 模版标题
	Content   string `json:"content"`   // 模版内容
	Example   string `json:"example"`   // 模板内容示例
	SubType   int    `json:"type"`      // 模版类型,2 为一次性订阅,3 为长期订阅
}

PrivateSubscribeItem 私有订阅消息模板

type PublicTemplateCategory added in v2.1.4

type PublicTemplateCategory struct {
	ID   int    `json:"id"`   // 类目ID
	Name string `json:"name"` // 类目的中文名
}

PublicTemplateCategory 公众号类目

type PublicTemplateKeyWords added in v2.1.4

type PublicTemplateKeyWords struct {
	KeyWordsID int    `json:"kid"`     // 关键词 id
	Name       string `json:"name"`    // 关键词内容
	Example    string `json:"example"` // 关键词内容对应的示例
	Rule       string `json:"rule"`    // 参数类型
}

PublicTemplateKeyWords 模板中的关键词

type PublicTemplateTitle added in v2.1.4

type PublicTemplateTitle struct {
	TitleID    int    `json:"tid"`        // 模版标题 id
	Title      string `json:"title"`      // 模版标题
	Type       int    `json:"type"`       // 模版类型,2 为一次性订阅,3 为长期订阅
	CategoryID string `json:"categoryId"` // 模版所属类目 id
}

PublicTemplateTitle 类目下的公共模板

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 Subscribe added in v2.0.7

type Subscribe struct {
	*context.Context
}

Subscribe 订阅消息

func NewSubscribe added in v2.0.7

func NewSubscribe(context *context.Context) *Subscribe

NewSubscribe 实例化

func (*Subscribe) Add added in v2.0.9

func (tpl *Subscribe) Add(ShortID string, kidList []int, sceneDesc string) (templateID string, err error)

Add 添加订阅消息模板

func (*Subscribe) Delete added in v2.0.9

func (tpl *Subscribe) Delete(templateID string) (err error)

Delete 删除私有模板

func (*Subscribe) GetCategory added in v2.1.4

func (tpl *Subscribe) GetCategory() (categoryList []*PublicTemplateCategory, err error)

GetCategory 获取公众号类目

func (*Subscribe) GetPubTplKeyWordsByID added in v2.1.4

func (tpl *Subscribe) GetPubTplKeyWordsByID(titleID string) (keyWordsList []*PublicTemplateKeyWords, err error)

GetPubTplKeyWordsByID 获取模板中的关键词

func (*Subscribe) GetPublicTemplateTitleList added in v2.1.4

func (tpl *Subscribe) GetPublicTemplateTitleList(ids string, start int, limit int) (count int, templateTitleList []*PublicTemplateTitle, err error)

GetPublicTemplateTitleList 获取类目下的公共模板

func (*Subscribe) List added in v2.0.7

func (tpl *Subscribe) List() (templateList []*PrivateSubscribeItem, err error)

List 获取私有订阅消息模板列表

func (*Subscribe) Send added in v2.0.7

func (tpl *Subscribe) Send(msg *SubscribeMessage) (err error)

Send 发送订阅消息

type SubscribeDataItem added in v2.0.6

type SubscribeDataItem struct {
	Value string `json:"value"`
}

SubscribeDataItem 模版内某个 .DATA 的值

type SubscribeMessage added in v2.0.6

type SubscribeMessage struct {
	ToUser      string                        `json:"touser"`         // 必须, 接受者OpenID
	TemplateID  string                        `json:"template_id"`    // 必须, 模版ID
	Page        string                        `json:"page,omitempty"` // 可选, 跳转网页时填写
	Data        map[string]*SubscribeDataItem `json:"data"`           // 必须, 模板数据
	MiniProgram struct {
		AppID    string `json:"appid"`    // 所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系)
		PagePath string `json:"pagepath"` // 所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar)
	} `json:"miniprogram"` // 可选,跳转至小程序地址
}

SubscribeMessage 发送的订阅消息内容

type SubscribeMsgPopupEvent added in v2.1.0

type SubscribeMsgPopupEvent struct {
	TemplateID            string `xml:"TemplateId" json:"TemplateId"`
	SubscribeStatusString string `xml:"SubscribeStatusString" json:"SubscribeStatusString"`
	PopupScene            int    `xml:"PopupScene" json:"PopupScene,string"`
}

SubscribeMsgPopupEvent 订阅通知事件推送的消息体

type Template

type Template struct {
	*context.Context
}

Template 模板消息

func NewTemplate

func NewTemplate(context *context.Context) *Template

NewTemplate 实例化

func (*Template) Add added in v2.0.7

func (tpl *Template) Add(shortID string) (templateID string, err error)

Add 添加模板.

func (*Template) Delete added in v2.0.7

func (tpl *Template) Delete(templateID string) (err error)

Delete 删除私有模板.

func (*Template) List added in v2.0.2

func (tpl *Template) List() (templateList []*TemplateItem, err error)

List 获取模板列表

func (*Template) Send

func (tpl *Template) Send(msg *TemplateMessage) (msgID int64, err error)

Send 发送模板消息

type TemplateDataItem

type TemplateDataItem struct {
	Value string `json:"value"`
	Color string `json:"color,omitempty"`
}

TemplateDataItem 模版内某个 .DATA 的值

type TemplateItem added in v2.0.2

type TemplateItem struct {
	TemplateID      string `json:"template_id"`
	Title           string `json:"title"`
	PrimaryIndustry string `json:"primary_industry"`
	DeputyIndustry  string `json:"deputy_industry"`
	Content         string `json:"content"`
	Example         string `json:"example"`
}

TemplateItem 模板消息.

type TemplateMessage

type TemplateMessage struct {
	ToUser     string                       `json:"touser"`          // 必须, 接受者OpenID
	TemplateID string                       `json:"template_id"`     // 必须, 模版ID
	URL        string                       `json:"url,omitempty"`   // 可选, 用户点击后跳转的URL, 该URL必须处于开发者在公众平台网站中设置的域中
	Color      string                       `json:"color,omitempty"` // 可选, 整个消息的颜色, 可以不设置
	Data       map[string]*TemplateDataItem `json:"data"`            // 必须, 模板数据

	MiniProgram struct {
		AppID    string `json:"appid"`    // 所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系)
		PagePath string `json:"pagepath"` // 所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar)
	} `json:"miniprogram"` // 可选,跳转至小程序地址
}

TemplateMessage 发送的模板消息内容

type Text

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

Text 文本消息

func NewText

func NewText(content string) *Text

NewText 初始化文本消息

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     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