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

68 lines
1.0 KiB

  1. package weixinrpc
  2. const DES_KEY = "wxserrpc"
  3. type WxApiRes struct {
  4. Errcode int
  5. Errmsg string
  6. }
  7. type Req struct {
  8. SiteId string
  9. Dbname string
  10. }
  11. type AccessTokenReq struct {
  12. Req
  13. Appid string
  14. Secret string
  15. }
  16. type AccessTokenRes struct {
  17. AccessToken string
  18. }
  19. type UniformMessageReq struct {
  20. Req
  21. Appid string
  22. Secret string
  23. Touser string
  24. MpAppid string
  25. TemplateId string
  26. Url string
  27. MiniProgram interface{}
  28. Data interface{}
  29. }
  30. /**
  31. * 获取小程序openid请求参数
  32. */
  33. type MiniAppOpenidReq struct {
  34. Appid string
  35. Secret string
  36. JsCode string
  37. }
  38. /**
  39. * 获取小程序openid返回参数
  40. */
  41. type MiniAppOpenidReqRes struct {
  42. Openid string
  43. SessionKey string
  44. Unionid string
  45. WxApiRes
  46. }
  47. func rpc_server_conn(url ...string) (*WeixinRpcServiceClient, error) {
  48. var wx_rpc_url string = "127.0.0.1:7969"
  49. if len(url) > 0 && url[0] != "" {
  50. wx_rpc_url = url[0]
  51. }
  52. conn, _, err := DialWeixinRpcService("tcp", wx_rpc_url)
  53. if err != nil {
  54. return nil, err
  55. }
  56. return conn, nil
  57. }