customer message
This commit is contained in:
parent
c714db19b0
commit
616f26f45b
|
@ -234,14 +234,42 @@ func (q *AppCustomer) GetCustomerInfo(externalUserid string) (*CustomerInfo, err
|
|||
}
|
||||
|
||||
func (a *AppCustomer) SendCustomerText(openKfId, toUser, content string) error {
|
||||
return a.sendCustomerMessage(openKfId, toUser, "text", map[string]interface{}{
|
||||
"content": content,
|
||||
})
|
||||
}
|
||||
|
||||
func (a *AppCustomer) SendCustomerVideo(openKfId, toUser, mediaId string) error {
|
||||
return a.sendCustomerMessage(openKfId, toUser, "video", map[string]interface{}{
|
||||
"media_id": mediaId,
|
||||
})
|
||||
}
|
||||
|
||||
func (a *AppCustomer) SendCustomerImage(openKfId, toUser, mediaId string) error {
|
||||
return a.sendCustomerMessage(openKfId, toUser, "image", map[string]interface{}{
|
||||
"media_id": mediaId,
|
||||
})
|
||||
}
|
||||
|
||||
func (a *AppCustomer) SendCustomerVoice(openKfId, toUser, mediaId string) error {
|
||||
return a.sendCustomerMessage(openKfId, toUser, "voice", map[string]interface{}{
|
||||
"media_id": mediaId,
|
||||
})
|
||||
}
|
||||
|
||||
func (a *AppCustomer) SendCustomerFile(openKfId, toUser, mediaId string) error {
|
||||
return a.sendCustomerMessage(openKfId, toUser, "file", map[string]interface{}{
|
||||
"media_id": mediaId,
|
||||
})
|
||||
}
|
||||
|
||||
func (a *AppCustomer) sendCustomerMessage(openKfId, toUser, msgtype string, data interface{}) error {
|
||||
reqUrl := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/kf/send_msg?access_token=%s", a.GetToken())
|
||||
params := make(map[string]interface{})
|
||||
params["touser"] = toUser
|
||||
params["open_kfid"] = openKfId
|
||||
params["msgtype"] = "text"
|
||||
params["text"] = map[string]interface{}{
|
||||
"content": content,
|
||||
}
|
||||
params["msgtype"] = msgtype
|
||||
params[msgtype] = data
|
||||
reqBody, _ := json.Marshal(params)
|
||||
rspBody, err := util.HttpPostJson(reqUrl, nil, reqBody)
|
||||
if err != nil {
|
||||
|
@ -253,6 +281,7 @@ func (a *AppCustomer) SendCustomerText(openKfId, toUser, content string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *AppCustomer) SyncMessage(openKfId, cursor, token string) ([]*CustomerMessage, string, error) {
|
||||
reqUrl := fmt.Sprintf("https://qyapi.weixin.qq.com/cgi-bin/kf/sync_msg?access_token=%s", a.GetToken())
|
||||
params := make(map[string]interface{})
|
||||
|
|
Loading…
Reference in New Issue