template

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2015 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

模板消息接口.

Index

Constants

View Source
const (
	TemplateSendStatusSuccess            = "success"               // 送达成功时
	TemplateSendStatusFailedUserBlock    = "failed:user block"     // 送达由于用户拒收(用户设置拒绝接收公众号消息)而失败
	TemplateSendStatusFailedSystemFailed = "failed: system failed" // 送达由于其他原因失败
)
View Source
const (
	EventTypeTemplateSendJobFinish = "TEMPLATESENDJOBFINISH"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*mp.WechatClient
}

func NewClient

func NewClient(AccessTokenServer mp.AccessTokenServer, httpClient *http.Client) Client

兼容保留, 建議實際項目全局維護一個 *mp.WechatClient

func (Client) AddTemplate

func (clt Client) AddTemplate(templateIdShort string) (templateId string, err error)

从行业模板库选择模板添加到账号后台, 并返回模板id.

templateIdShort: 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式.

func (Client) Send

func (clt Client) Send(msg *TemplateMessage) (msgid int64, err error)

发送模板消息

func (Client) SetIndustry

func (clt Client) SetIndustry(industryId ...int64) (err error)

设置所属行业.

目前 industryId 的个数只能为 2.

type TemplateMessage

type TemplateMessage struct {
	ToUser     string `json:"touser"`             // 必须, 接受者OpenID
	TemplateId string `json:"template_id"`        // 必须, 模版ID
	URL        string `json:"url,omitempty"`      // 可选, 用户点击后跳转的URL,该URL必须处于开发者在公众平台网站中设置的域中
	TopColor   string `json:"topcolor,omitempty"` // 可选, 整个消息的颜色, 可以不设置

	// 必须, JSON 格式的 []byte, 满足特定的模板需求
	RawJSONData json.RawMessage `json:"data"`
}

type TemplateSendJobFinishEvent

type TemplateSendJobFinishEvent struct {
	XMLName struct{} `xml:"xml" json:"-"`
	mp.CommonMessageHeader

	Event  string `xml:"Event"  json:"Event"` // 事件信息,此处为 TEMPLATESENDJOBFINISH
	MsgId  int64  `xml:"MsgId"  json:"MsgId"` // 模板消息ID
	Status string `xml:"Status" json:"Status"`
}

在模版消息发送任务完成后,微信服务器会将是否送达成功作为通知,发送到开发者中心中填写的服务器配置地址中。

func GetTemplateSendJobFinishEvent

func GetTemplateSendJobFinishEvent(msg *mp.MixedMessage) *TemplateSendJobFinishEvent

Jump to

Keyboard shortcuts

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