SendCustomerText

This commit is contained in:
jiangyong27 2024-01-23 18:28:28 +08:00
parent dc438c9536
commit ba17643c79
1 changed files with 20 additions and 0 deletions

View File

@ -60,6 +60,26 @@ func (a *AppCustomer) AccountList() ([]*CustomerAccount, error) {
return accounts, nil
}
func (a *AppCustomer) SendCustomerText(toUser, openKfId, content string) 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["msg_type"] = "text"
params["text"] = map[string]interface{}{
"content": content,
}
reqBody, _ := json.Marshal(params)
rspBody, err := util.HttpPostJson(reqUrl, nil, reqBody)
if err != nil {
return err
}
_, err = a.GetResult(rspBody)
if err != nil {
return err
}
return nil
}
func (a *AppCustomer) SyncMessage(cursor, token, openKfId 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{})