github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/message/mass/preview/preview.go (about) 1 // 预览消息. 2 package preview 3 4 import ( 5 "github.com/chanxuehong/wechat/mp/core" 6 ) 7 8 // Send 发送消息, msg 是经过 encoding/json.Marshal 得到的结果符合微信消息格式的任何数据结构. 9 func Send(clt *core.Client, msg interface{}) (err error) { 10 const incompleteURL = "https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=" 11 12 var result core.Error 13 if err = clt.PostJSON(incompleteURL, msg, &result); err != nil { 14 return 15 } 16 if result.ErrCode != core.ErrCodeOK { 17 err = &result 18 return 19 } 20 return 21 }