Closed zzir closed 3 years ago
V3版本可以通过这种方式使用:
import "medivhzhan/weapp/v3"
cli:= weapp.NewClient("appid","secret")
submsg := cli.NewSubscribeMessage()
submsg.send(&subscribemessage.SendRequest{})
看到官方文档 data 类型是 Object,尝试
submsg.Send(&subscribemessage.SendRequest{
ToUser: "todo",
TemplateID: "todo",
Page: "todo",
MiniprogramState: "todo",
Data: "{ \"key1\": { \"value\": any }, \"key2\": { \"value\": any } }",
})
会报错找不到 key
用map把内容Marshal为JSON字符串再赋值给Data
然后确认传入的模板相关数据都是正确的
文档里的 SubscribeMessageData{} 结构没有找到,当把消息模版参数转换为字符给 data 时,消息发送失败