package wechat
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
//发送订阅消息返回结果
|
|
type SendSubscribeMessageData struct {
|
|
Errcode int `json:"errcode"`
|
|
Errmsg string `json:"errmsg"`
|
|
}
|
|
|
|
//发送统一消息返回结果
|
|
type SendUniformMessageData struct {
|
|
Errcode int `json:"errcode"`
|
|
Errmsg string `json:"errmsg"`
|
|
}
|
|
|
|
func SendSubscribeMessage(access_token string, message []byte) (SendSubscribeMessageData, error) {
|
|
|
|
url := fmt.Sprintf(MINIAPP_SUBSCRIBE_MESSAGE_SEND_API, access_token)
|
|
|
|
ret, err := PostJson(url, message)
|
|
|
|
var data SendSubscribeMessageData
|
|
|
|
if err != nil {
|
|
|
|
return data, err
|
|
}
|
|
|
|
err = json.Unmarshal(ret, &data)
|
|
|
|
return data, err
|
|
}
|
|
|
|
func SendUniformMessage(access_token string, message []byte) (SendUniformMessageData, error) {
|
|
|
|
url := fmt.Sprintf(MINIAPP_UNIFORM_MESSAGE_API, access_token)
|
|
|
|
ret, err := PostJson(url, message)
|
|
|
|
var data SendUniformMessageData
|
|
|
|
if err != nil {
|
|
|
|
return data, err
|
|
}
|
|
|
|
err = json.Unmarshal(ret, &data)
|
|
|
|
return data, err
|
|
}
|