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