|
|
|
@@ -1,6 +1,7 @@ |
|
|
|
package main |
|
|
|
|
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"log" |
|
|
|
@@ -28,10 +29,20 @@ func kfSendTxt(user, txt string) { |
|
|
|
s.Text.Content = txt |
|
|
|
s.ToUser = user |
|
|
|
|
|
|
|
j, _ := json.Marshal(s) |
|
|
|
//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) |
|
|
|
encoder.SetEscapeHTML(false) |
|
|
|
err := encoder.Encode(t) |
|
|
|
return buffer.Bytes(), err |
|
|
|
} |
|
|
|
|
|
|
|
type sendPicMsg struct { |
|
|
|
ToUser string `json:"touser"` |
|
|
|
MsgType string `json:"msgtype"` |