|
|
@ -2,12 +2,13 @@ package weixinrpc |
|
|
|
|
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"strconv" |
|
|
|
"time" |
|
|
|
"git.tetele.net/tgo/crypter" |
|
|
|
"github.com/golang/protobuf/proto" |
|
|
|
"strconv" |
|
|
|
"time" |
|
|
|
) |
|
|
|
|
|
|
|
//检测图片是否合法
|
|
|
|
func ImgSecCheck(appId, appSecret,imgUrl string, url ...string) (error) { |
|
|
|
|
|
|
|
conn, err := rpc_server_conn(url...) |
|
|
@ -42,7 +43,7 @@ func ImgSecCheck(appId, appSecret,imgUrl string, url ...string) (error) { |
|
|
|
|
|
|
|
res := &Response{} |
|
|
|
|
|
|
|
err = conn.GetMiniappQrcode(req, res) |
|
|
|
err = conn.ImgSecCheck(req, res) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
return err |
|
|
@ -51,3 +52,46 @@ func ImgSecCheck(appId, appSecret,imgUrl string, url ...string) (error) { |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//检测文本是否合法
|
|
|
|
func MsgSecCheck(appId, appSecret string,checkData map[string]interface{}, url ...string)error{ |
|
|
|
conn, err := rpc_server_conn(url...) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
defer conn.Close() |
|
|
|
|
|
|
|
data := map[string]interface{}{} |
|
|
|
data["app_id"] = appId |
|
|
|
data["app_secret"] = appSecret |
|
|
|
data["check_data"] = checkData |
|
|
|
|
|
|
|
data_json, err := json.Marshal(data) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
encryData := crypter.DesEn(string(data_json), DES_KEY) |
|
|
|
|
|
|
|
now_int64 := time.Now().Unix() |
|
|
|
|
|
|
|
now := strconv.FormatInt(now_int64, 10) |
|
|
|
|
|
|
|
sign := Sign(encryData, now) |
|
|
|
|
|
|
|
req := &Request{ |
|
|
|
proto.String(encryData), |
|
|
|
proto.String(now), |
|
|
|
proto.String(sign), |
|
|
|
nil} |
|
|
|
|
|
|
|
res := &Response{} |
|
|
|
|
|
|
|
err = conn.MsgSecCheck(req, res) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
return nil |
|
|
|
} |