修改企业微信
This commit is contained in:
@@ -10,11 +10,11 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const token = "nn3P9sfkGK5UlHgtNoAqB"
|
||||
const receiverId = "ww9a156bfa070e1857"
|
||||
const encodingAeskey = "471RkJkfISWJQUC2f8DSdOgXH0reVCxWCpfaTawSIWA"
|
||||
const Token = "nn3P9sfkGK5UlHgtNoAqB"
|
||||
const ReceiverId = "ww9a156bfa070e1857"
|
||||
const EncodingAeskey = "471RkJkfISWJQUC2f8DSdOgXH0reVCxWCpfaTawSIWA"
|
||||
|
||||
func getString(str, endstr string, start int, msg *string) int {
|
||||
func GetString(str, endstr string, start int, msg *string) int {
|
||||
end := strings.Index(str, endstr)
|
||||
*msg = str[start:end]
|
||||
return end + len(endstr)
|
||||
@@ -28,20 +28,20 @@ func VerifyURL(w http.ResponseWriter, r *http.Request) {
|
||||
start += len("msg_signature=")
|
||||
|
||||
var msg_signature string
|
||||
next := getString(httpstr, "×tamp=", start, &msg_signature)
|
||||
next := GetString(httpstr, "×tamp=", start, &msg_signature)
|
||||
|
||||
var timestamp string
|
||||
next = getString(httpstr, "&nonce=", next, ×tamp)
|
||||
next = GetString(httpstr, "&nonce=", next, ×tamp)
|
||||
|
||||
var nonce string
|
||||
next = getString(httpstr, "&echostr=", next, &nonce)
|
||||
next = GetString(httpstr, "&echostr=", next, &nonce)
|
||||
|
||||
echostr := httpstr[next:len(httpstr)]
|
||||
|
||||
echostr, _ = url.QueryUnescape(echostr)
|
||||
fmt.Println(msg_signature, timestamp, nonce, echostr, next)
|
||||
|
||||
wxcpt := NewWXBizMsgCrypt(token, encodingAeskey, receiverId, JsonType)
|
||||
wxcpt := NewWXBizMsgCrypt(Token, EncodingAeskey, ReceiverId, JsonType)
|
||||
echoStr, cryptErr := wxcpt.VerifyURL(msg_signature, timestamp, nonce, echostr)
|
||||
if nil != cryptErr {
|
||||
fmt.Println("verifyUrl fail", cryptErr)
|
||||
@@ -57,19 +57,19 @@ func MsgHandler(w http.ResponseWriter, r *http.Request) {
|
||||
start += len("msg_signature=")
|
||||
|
||||
var msg_signature string
|
||||
next := getString(httpstr, "×tamp=", start, &msg_signature)
|
||||
next := GetString(httpstr, "×tamp=", start, &msg_signature)
|
||||
|
||||
var timestamp string
|
||||
next = getString(httpstr, "&nonce=", next, ×tamp)
|
||||
next = GetString(httpstr, "&nonce=", next, ×tamp)
|
||||
|
||||
nonce := httpstr[next:len(httpstr)]
|
||||
fmt.Println(msg_signature, timestamp, nonce)
|
||||
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
fmt.Println(string(body), err)
|
||||
wxcpt := NewWXBizMsgCrypt(token, encodingAeskey, receiverId, JsonType)
|
||||
|
||||
wxcpt := NewWXBizMsgCrypt(Token, EncodingAeskey, ReceiverId, JsonType)
|
||||
msg, err_ := wxcpt.DecryptMsg(msg_signature, timestamp, nonce, body)
|
||||
|
||||
fmt.Println(string(msg), err_)
|
||||
var msgContent MsgContent
|
||||
err = json.Unmarshal(msg, &msgContent)
|
||||
|
||||
Reference in New Issue
Block a user