微信接口的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.

61 lines
1018 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 GetMiniAppQrcode(appId, appSecret string, qrcodeParams map[string]interface{}, url ...string) (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["qrcode"] = qrcodeParams
  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. //解密
  38. res_data_de, err := GetOrgData(res)
  39. if err != nil {
  40. return "", err
  41. }
  42. return res_data_de, nil
  43. }