5
5
"net/url"
6
6
)
7
7
8
- const WeAPPRegisterUrl = "https://api.weixin.qq.com/cgi-bin/component/fastregisterweapp?"
8
+ const OrgWeAPPRegisterUrl = "https://api.weixin.qq.com/cgi-bin/component/fastregisterweapp?"
9
+ const PersonalWeAPPRegisterUrl = "https://api.weixin.qq.com/wxa/component/fastregisterpersonalweapp?"
9
10
10
11
type FastRegisterWeappReq struct {
11
12
Name string `json:"name"` //企业名
@@ -16,8 +17,9 @@ type FastRegisterWeappReq struct {
16
17
ComponentPhone string `json:"component_phone"` //第三方联系电话
17
18
}
18
19
19
- //快速注册小程序
20
+ // FastRegisterWeapp 快速注册小程序
20
21
//https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/Fast_Registration_Interface_document.html
22
+ //Deprecated: 转用 FastRegisterOrgWeapp 方法
21
23
func (s * Server ) FastRegisterWeapp (req * FastRegisterWeappReq ) (resp * core.Error ) {
22
24
var (
23
25
p = make (url.Values )
@@ -33,7 +35,37 @@ func (s *Server) FastRegisterWeapp(req *FastRegisterWeappReq) (resp *core.Error)
33
35
}
34
36
p .Set ("action" , "create" )
35
37
p .Set ("component_access_token" , token )
36
- resp .Err (core .PostJson (WeAPPRegisterUrl + p .Encode (), req , resp ))
38
+ resp .Err (core .PostJson (OrgWeAPPRegisterUrl + p .Encode (), req , resp ))
39
+ return
40
+ }
41
+
42
+ type FastRegisterOrgWeappReq struct {
43
+ Name string `json:"name"` //企业名
44
+ Code string `json:"code"` //企业代码
45
+ CodeType int8 `json:"code_type"` //企业代码类型(1:统一社会信用代码, 2:组织机构代码,3:营业执照注册号)
46
+ LegalPersonaWechat string `json:"legal_persona_wechat"` //法人微信
47
+ LegalPersonaName string `json:"legal_persona_name"` //法人姓名(绑定银行卡)
48
+ ComponentPhone string `json:"component_phone"` //第三方联系电话
49
+ }
50
+
51
+ // FastRegisterOrgWeapp 快速注册小程序
52
+ //https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/Fast_Registration_Interface_document.html
53
+ func (s * Server ) FastRegisterOrgWeapp (req * FastRegisterWeappReq ) (resp * core.Error ) {
54
+ var (
55
+ p = make (url.Values )
56
+ token string
57
+ err error
58
+ )
59
+ resp = & core.Error {}
60
+
61
+ token , err = s .Token ()
62
+ if err != nil {
63
+ resp .Err (err )
64
+ return
65
+ }
66
+ p .Set ("action" , "create" )
67
+ p .Set ("component_access_token" , token )
68
+ resp .Err (core .PostJson (OrgWeAPPRegisterUrl + p .Encode (), req , resp ))
37
69
return
38
70
}
39
71
@@ -43,8 +75,9 @@ type SearchWeappReq struct {
43
75
LegalPersonaName string `json:"legal_persona_name"` //法人姓名(绑定银行卡)
44
76
}
45
77
46
- //查询创建任务状态
78
+ // SearchWeapp 查询创建任务状态
47
79
//https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/Fast_Registration_Interface_document.html
80
+ //Deprecated: 转用 QueryOrgWeapp 方法
48
81
func (s * Server ) SearchWeapp (req * SearchWeappReq ) (resp * core.Error ) {
49
82
var (
50
83
p = make (url.Values )
@@ -59,6 +92,96 @@ func (s *Server) SearchWeapp(req *SearchWeappReq) (resp *core.Error) {
59
92
}
60
93
p .Set ("action" , "search" )
61
94
p .Set ("component_access_token" , token )
62
- resp .Err (core .PostJson (WeAPPRegisterUrl + p .Encode (), req , resp ))
95
+ resp .Err (core .PostJson (OrgWeAPPRegisterUrl + p .Encode (), req , resp ))
96
+ return
97
+ }
98
+
99
+ type QueryOrgWeappReq struct {
100
+ Name string `json:"name"` //企业名
101
+ LegalPersonaWechat string `json:"legal_persona_wechat"` //法人微信
102
+ LegalPersonaName string `json:"legal_persona_name"` //法人姓名(绑定银行卡)
103
+ }
104
+
105
+ // QueryOrgWeapp 查询创建任务状态
106
+ //https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/Fast_Registration_Interface_document.html
107
+ func (s * Server ) QueryOrgWeapp (req * SearchWeappReq ) (resp * core.Error ) {
108
+ var (
109
+ p = make (url.Values )
110
+ token string
111
+ err error
112
+ )
113
+ resp = & core.Error {}
114
+ token , err = s .Token ()
115
+ if err != nil {
116
+ resp .Err (err )
117
+ return
118
+ }
119
+ p .Set ("action" , "search" )
120
+ p .Set ("component_access_token" , token )
121
+ resp .Err (core .PostJson (OrgWeAPPRegisterUrl + p .Encode (), req , resp ))
122
+ return
123
+ }
124
+
125
+ type FastRegisterPersonalWeappReq struct {
126
+ IdName string `json:"idname"` //个人用户名称
127
+ WxUser string `json:"wxuser"` //个人用户微信号
128
+ ComponentPhone * string `json:"component_phone,omitempty"` //第三方联系电话
129
+ }
130
+
131
+ type FastRegisterPersonalWeappResp struct {
132
+ core.Error
133
+ taskid string // 任务id,后面query查询需要用到
134
+ authorize_url string // 给用户扫码认证的验证url
135
+ status int // 任务的状态
136
+ }
137
+
138
+ // FastRegisterPersonalWeapp 快速注册个人小程序
139
+ //https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/fastregisterpersonalweapp.html
140
+ func (s * Server ) FastRegisterPersonalWeapp (req * FastRegisterPersonalWeappReq ) (resp * FastRegisterPersonalWeappResp ) {
141
+ var (
142
+ p = make (url.Values )
143
+ token string
144
+ err error
145
+ )
146
+ resp = & FastRegisterPersonalWeappResp {}
147
+
148
+ token , err = s .Token ()
149
+ if err != nil {
150
+ resp .Err (err )
151
+ return
152
+ }
153
+ p .Set ("action" , "create" )
154
+ p .Set ("component_access_token" , token )
155
+ resp .Err (core .PostJson (PersonalWeAPPRegisterUrl + p .Encode (), req , resp ))
156
+ return
157
+ }
158
+
159
+ type QueryPersonalWeappResp struct {
160
+ core.Error
161
+ TaskId string `json:"taskid"`
162
+ AuthorizeUrl string `json:"authorize_url"`
163
+ Status int `json:"status"`
164
+ }
165
+
166
+ //查询个人小程序创建任务状态接口详情
167
+ //https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Register_Mini_Programs/fastregisterpersonalweapp.html
168
+ func (s * Server ) QueryPersonalWeapp (taskId string ) (resp * QueryPersonalWeappResp ) {
169
+ var (
170
+ p = make (url.Values )
171
+ token string
172
+ err error
173
+ req = & struct {
174
+ TaskId string `json:"taskid"`
175
+ }{TaskId : taskId }
176
+ )
177
+ resp = & QueryPersonalWeappResp {}
178
+ token , err = s .Token ()
179
+ if err != nil {
180
+ resp .Err (err )
181
+ return
182
+ }
183
+ p .Set ("action" , "query" )
184
+ p .Set ("component_access_token" , token )
185
+ resp .Err (core .PostJson (PersonalWeAPPRegisterUrl + p .Encode (), req , resp ))
63
186
return
64
187
}
0 commit comments