|
|
|
@@ -19,6 +19,9 @@ type sendTxtMsg struct { |
|
|
|
Text struct { |
|
|
|
Content string `json:"content"` |
|
|
|
} `json:"text"` |
|
|
|
CustomerService struct { |
|
|
|
KfAccount string `json:"kf_account"` |
|
|
|
} `json:"customservice"` |
|
|
|
} |
|
|
|
|
|
|
|
func kfSendTxt(user, txt string) { |
|
|
|
@@ -35,6 +38,20 @@ func kfSendTxt(user, txt string) { |
|
|
|
postJSON(j, u) |
|
|
|
} |
|
|
|
|
|
|
|
func kfSendTxtAs(user, txt, KF string) { |
|
|
|
u := getKfSendURL() |
|
|
|
|
|
|
|
s := sendTxtMsg{} |
|
|
|
s.MsgType = "text" |
|
|
|
s.Text.Content = txt |
|
|
|
s.ToUser = user |
|
|
|
s.CustomerService.KfAccount = KFUsers.kfAcc(KF) |
|
|
|
//j, _ := json.Marshal(s) // it will escape html < > and & to \u0006 |
|
|
|
j, _ := myJSONMarshal(s) // this reserves < > and & |
|
|
|
log.Println(string(j)) |
|
|
|
postJSON(j, u) |
|
|
|
} |
|
|
|
|
|
|
|
func myJSONMarshal(t interface{}) ([]byte, error) { |
|
|
|
buffer := &bytes.Buffer{} |
|
|
|
encoder := json.NewEncoder(buffer) |