Browse Source

加入检测方法

master
listen 3 years ago
parent
commit
131fea8347
2 changed files with 55 additions and 0 deletions
  1. +53
    -0
      security_check.go
  2. +2
    -0
      weixin.proto

+ 53
- 0
security_check.go View File

@ -0,0 +1,53 @@
package weixinrpc
import (
"encoding/json"
"strconv"
"time"
"git.tetele.net/tgo/crypter"
"github.com/golang/protobuf/proto"
)
func ImgSecCheck(appId, appSecret,imgUrl string, 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["img_url"] = imgUrl
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.GetMiniappQrcode(req, res)
if err != nil {
return err
}
return nil
}

+ 2
- 0
weixin.proto View File

@ -26,4 +26,6 @@ service WeixinRpcService {
rpc getAppOpenid(Request) returns (Response); // app的openid rpc getAppOpenid(Request) returns (Response); // app的openid
rpc getMpUserInfo(Request) returns (Response); // rpc getMpUserInfo(Request) returns (Response); //
rpc getMiniappQrcode(Request) returns (Response); // rpc getMiniappQrcode(Request) returns (Response); //
rpc imgSecCheck(Request) returns (Response); //
rpc msgSecCheck(Request) returns (Response); //
} }

Loading…
Cancel
Save