-
Notifications
You must be signed in to change notification settings - Fork 4
/
template.go
43 lines (38 loc) · 989 Bytes
/
template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package example
import (
"fmt"
"github.com/yijizhichang/wechat-sdk/examples/wxconf"
"github.com/yijizhichang/wechat-sdk/mp/message/template"
)
//发送模板消息
func SendTemplateMsg() {
//NewWechat
tpl := wxconf.WechatClient.GetTemplate()
//模板参数
first := &template.DataItem{
"亲爱的xxx,您本月的收益情况为",
"#FF4040",
}
remark := &template.DataItem{
"感谢您的使用,祝您生活愉快~",
"#FF00FF",
}
keyword1 := &template.DataItem{
"500大洋",
"#CAFF70",
}
keyword2 := &template.DataItem{
"手机",
"#9932CC",
}
msgTest2 := new(template.Message)
msgTest2.ToUser = "abcd1234abcd1234abcd1234"
msgTest2.TemplateID = "MYl2aWAlESuuCVZ-KyOzxWFlUZ0Gp95fO2mXXXXXXX"
msgTest2.Data = make(map[string]*template.DataItem)
msgTest2.Data["first"] = first
msgTest2.Data["keyword1"] = keyword1
msgTest2.Data["keyword2"] = keyword2
msgTest2.Data["remark"] = remark
re, _ := tpl.Send(msgTest2)
fmt.Println("返回结果:", re)
}