// Response returns the response body data for the request from wechat mp platform. func (h *recvHandler) Response(msg []byte, encryptType string) ([]byte, error) { if encryptType == "aes" { msgEncrypt, err := EncryptMsg(msg, h.appID, h.encodingAESKey) if err != nil { return nil, err } nonce := pb.GenNonce() timestamp := pb.GenTimestamp() signature := pb.GenSignature(h.token, fmt.Sprintf("%d", timestamp), nonce, msgEncrypt) resp := &RecvHTTPEncryptRespBody{ Encrypt: pb.String2CDATA(msgEncrypt), MsgSignature: pb.String2CDATA(signature), TimeStamp: timestamp, Nonce: pb.String2CDATA(nonce), } return xml.MarshalIndent(resp, " ", " ") } return msg, nil }
// dev_msg_signature=sha1(sort(token、timestamp、nonce、msg_encrypt)) func genSignature(token, timestamp, nonce, msgEncrypt string) string { return pb.GenSignature(token, timestamp, nonce, msgEncrypt) }
func genSignature(token, timestamp, nonce string) string { return pb.GenSignature(token, timestamp, nonce) }