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

62 lines
1.0 KiB

  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(siteId, 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["site_id"] = siteId
  17. data["app_id"] = appId
  18. data["app_secret"] = appSecret
  19. data["qrcode"] = qrcodeParams
  20. data_json, err := json.Marshal(data)
  21. if err != nil {
  22. return "", err
  23. }
  24. encryData := crypter.DesEn(string(data_json), DES_KEY)
  25. now_int64 := time.Now().Unix()
  26. now := strconv.FormatInt(now_int64, 10)
  27. sign := Sign(encryData, now)
  28. req := &Request{
  29. proto.String(encryData),
  30. proto.String(now),
  31. proto.String(sign),
  32. nil}
  33. res := &Response{}
  34. err = conn.GetMiniappQrcode(req, res)
  35. if err != nil {
  36. return "", err
  37. }
  38. // 解密
  39. res_data_de, err := GetOrgData(res)
  40. if err != nil {
  41. return "", err
  42. }
  43. return res_data_de, nil
  44. }