-
Notifications
You must be signed in to change notification settings - Fork 2
/
sendmsg.go
51 lines (43 loc) · 1.24 KB
/
sendmsg.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
44
45
46
47
48
49
50
51
package qy
import (
"strings"
"github.com/bigwhite/gowechat/pb"
)
const (
sendURL = "https://qyapi.weixin.qq.com/cgi-bin/message/send"
)
type SendMsgTextPkg struct {
pb.SendMsgTextPkg
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
AgentID string `json:"agentid"`
Safe string `json:"safe,omitempty"`
}
type SendMsgImagePkg struct {
pb.SendMsgImagePkg
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
AgentID string `json:"agentid"`
Safe string `json:"safe,omitempty"`
}
type Article struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Url string `json:"url,omitempty"`
PicUrl string `json:"picurl,omitempty"`
}
type Articles struct {
Articles []Article `json:"articles"`
}
type SendMsgNewsPkg struct {
ToUserName string `json:"touser"`
ToParty string `json:"toparty,omitempty"`
ToTag string `json:"totag,omitempty"`
MsgType string `json:"msgtype"`
AgentID string `json:"agentid"`
News Articles `json:"news"`
}
func SendMsg(accessToken string, pkg interface{}) error {
r := strings.Join([]string{sendURL, "?access_token=", accessToken}, "")
return pb.SendMsg(r, pkg)
}