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

118 lines
1.8 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. type SubscribeMessageReq struct {
  31. Req
  32. Appid string
  33. Secret string
  34. Touser string
  35. TemplateId string
  36. Page string
  37. MiniprogramState string
  38. Lang string
  39. Data interface{}
  40. }
  41. /**
  42. * 获取小程序openid请求参数
  43. */
  44. type MiniAppOpenidReq struct {
  45. Appid string
  46. Secret string
  47. JsCode string
  48. }
  49. /**
  50. * 获取小程序openid返回参数
  51. */
  52. type MiniAppOpenidRes struct {
  53. Openid string
  54. SessionKey interface{}
  55. Unionid interface{}
  56. NickName string
  57. AvatarUrl string
  58. WxApiRes
  59. }
  60. /**
  61. * 获取公众号openid返回参数
  62. */
  63. type MpOpenidRes struct {
  64. AccessToken string
  65. ExpiresIn string
  66. RefreshToken string
  67. Openid string
  68. Scope string
  69. }
  70. /**
  71. * 获取公众号用户信息请求参数
  72. */
  73. type MpUserInfoReq struct {
  74. AccessToken string
  75. Openid string
  76. Lang string
  77. }
  78. /**
  79. * 根据用户access_token换取用户信息返回参数
  80. */
  81. type MpUserInfoRes struct {
  82. Openid string
  83. Nickname string
  84. Sex string
  85. Province string
  86. City string
  87. Country string
  88. Headimgurl string
  89. Privilege string
  90. Unionid string
  91. }
  92. func rpc_server_conn(url ...string) (*WeixinRpcServiceClient, error) {
  93. var wx_rpc_url string = "127.0.0.1:7969"
  94. if len(url) > 0 && url[0] != "" {
  95. wx_rpc_url = url[0]
  96. }
  97. conn, _, err := DialWeixinRpcService("tcp", wx_rpc_url)
  98. if err != nil {
  99. return nil, err
  100. }
  101. return conn, nil
  102. }