微信接口的RPC包
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
858 B

  1. package weixinrpc
  2. import (
  3. "encoding/json"
  4. "strconv"
  5. "time"
  6. "git.tetele.net/tgo/crypter"
  7. "github.com/golang/protobuf/proto"
  8. )
  9. func ImgSecCheck(appId, appSecret,imgUrl string, url ...string) (error) {
  10. conn, err := rpc_server_conn(url...)
  11. if err != nil {
  12. return err
  13. }
  14. defer conn.Close()
  15. data := map[string]interface{}{}
  16. data["app_id"] = appId
  17. data["app_secret"] = appSecret
  18. data["img_url"] = imgUrl
  19. data_json, err := json.Marshal(data)
  20. if err != nil {
  21. return err
  22. }
  23. encryData := crypter.DesEn(string(data_json), DES_KEY)
  24. now_int64 := time.Now().Unix()
  25. now := strconv.FormatInt(now_int64, 10)
  26. sign := Sign(encryData, now)
  27. req := &Request{
  28. proto.String(encryData),
  29. proto.String(now),
  30. proto.String(sign),
  31. nil}
  32. res := &Response{}
  33. err = conn.GetMiniappQrcode(req, res)
  34. if err != nil {
  35. return err
  36. }
  37. return nil
  38. }