diff --git a/qyweixin/app_customer.go b/qyweixin/app_customer.go index f9ecf4c..2d4c9e1 100644 --- a/qyweixin/app_customer.go +++ b/qyweixin/app_customer.go @@ -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{})