1
|
|
|
# -*- coding: utf-8 -*- |
2
|
10 |
|
from __future__ import absolute_import, unicode_literals |
3
|
|
|
|
4
|
10 |
|
from optionaldict import optionaldict |
5
|
|
|
|
6
|
10 |
|
from wechatpy.client.api.base import BaseWeChatAPI |
7
|
|
|
|
8
|
|
|
|
9
|
10 |
|
class WeChatWxa(BaseWeChatAPI): |
10
|
10 |
|
API_BASE_URL = 'https://api.weixin.qq.com/' |
11
|
|
|
|
12
|
10 |
|
def create_qrcode(self, path, width=430): |
13
|
|
|
""" |
14
|
|
|
创建小程序二维码(接口C:适用于需要的码数量较少的业务场景) |
15
|
|
|
详情请参考 |
16
|
|
|
https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html |
17
|
|
|
""" |
18
|
|
|
return self._post( |
19
|
|
|
'cgi-bin/wxaapp/createwxaqrcode', |
20
|
|
|
data={ |
21
|
|
|
'path': path, |
22
|
|
|
'width': width |
23
|
|
|
} |
24
|
|
|
) |
25
|
|
|
|
26
|
10 |
|
def get_wxa_code(self, |
27
|
|
|
path, |
28
|
|
|
width=430, |
29
|
|
|
auto_color=False, |
30
|
|
|
line_color={"r": "0", "g": "0", "b": "0"}, |
31
|
|
|
is_hyaline=False): |
32
|
|
|
""" |
33
|
|
|
创建小程序码(接口A: 适用于需要的码数量较少的业务场景) |
34
|
|
|
详情请参考 |
35
|
|
|
https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html |
36
|
|
|
""" |
37
|
|
|
return self._post( |
38
|
|
|
'wxa/getwxacode', |
39
|
|
|
data={ |
40
|
|
|
'path': path, |
41
|
|
|
'width': width, |
42
|
|
|
'auto_color': auto_color, |
43
|
|
|
'line_color': line_color, |
44
|
|
|
'is_hyaline': is_hyaline, |
45
|
|
|
} |
46
|
|
|
) |
47
|
|
|
|
48
|
10 |
|
def get_wxa_code_unlimited(self, |
49
|
|
|
scene, |
50
|
|
|
width=430, |
51
|
|
|
auto_color=False, |
52
|
|
|
line_color={"r": "0", "g": "0", "b": "0"}, |
53
|
|
|
page=None, |
54
|
|
|
is_hyaline=False): |
55
|
|
|
""" |
56
|
|
|
创建小程序码(接口B:适用于需要的码数量极多,或仅临时使用的业务场景) |
57
|
|
|
详情请参考 |
58
|
|
|
https://mp.weixin.qq.com/debug/wxadoc/dev/api/qrcode.html |
59
|
|
|
""" |
60
|
|
|
return self._post( |
61
|
|
|
'wxa/getwxacodeunlimit', |
62
|
|
|
data=optionaldict( |
63
|
|
|
scene=scene, |
64
|
|
|
page=page, |
65
|
|
|
width=width, |
66
|
|
|
auto_color=auto_color, |
67
|
|
|
line_color=line_color, |
68
|
|
|
is_hyaline=is_hyaline, |
69
|
|
|
) |
70
|
|
|
) |
71
|
|
|
|
72
|
10 |
|
def send_template_message(self, user_id, template_id, data, form_id, page=None, color=None, emphasis_keyword=None): |
73
|
|
|
""" |
74
|
|
|
发送模板消息 |
75
|
|
|
详情请参考 |
76
|
|
|
https://mp.weixin.qq.com/debug/wxadoc/dev/api/notice.html |
77
|
|
|
""" |
78
|
|
|
tpl_data = optionaldict( |
79
|
|
|
touser=user_id, |
80
|
|
|
template_id=template_id, |
81
|
|
|
page=page, |
82
|
|
|
form_id=form_id, |
83
|
|
|
data=data, |
84
|
|
|
color=color, |
85
|
|
|
emphasis_keyword=emphasis_keyword, |
86
|
|
|
) |
87
|
|
|
return self._post( |
88
|
|
|
'cgi-bin/message/wxopen/template/send', |
89
|
|
|
data=tpl_data |
90
|
|
|
) |
91
|
|
|
|
92
|
10 |
|
def send_subscribe_message(self, user_id, template_id, data, page=None): |
93
|
|
|
""" |
94
|
|
|
发送订阅消息 |
95
|
|
|
详情请参考 |
96
|
|
|
https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html |
97
|
|
|
""" |
98
|
|
|
subs_data = optionaldict( |
99
|
|
|
touser=user_id, |
100
|
|
|
template_id=template_id, |
101
|
|
|
page=page, |
102
|
|
|
data=data, |
103
|
|
|
) |
104
|
|
|
return self._post( |
105
|
|
|
'cgi-bin/message/subscribe/send', |
106
|
|
|
data=subs_data |
107
|
|
|
) |
108
|
|
|
|
109
|
10 |
|
def modify_domain(self, action, request_domain=(), wsrequest_domain=(), upload_domain=(), download_domain=()): |
110
|
|
|
""" |
111
|
|
|
修改小程序服务器授权域名 |
112
|
|
|
详情请参考 |
113
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489138143_WPbOO |
114
|
|
|
|
115
|
|
|
:param action: 增删改查的操作类型,仅支持 'add', 'delete', 'set', 'get' |
116
|
|
|
:param request_domain: request 合法域名 |
117
|
|
|
:param wsrequest_domain: socket 合法域名 |
118
|
|
|
:param upload_domain: upload file 合法域名 |
119
|
|
|
:param download_domain: download file 合法域名 |
120
|
|
|
""" |
121
|
|
|
return self._post( |
122
|
|
|
'wxa/modify_domain', |
123
|
|
|
data={ |
124
|
|
|
'action': action, |
125
|
|
|
'requestdomain': request_domain, |
126
|
|
|
'wsrequestdomain': wsrequest_domain, |
127
|
|
|
'uploaddomain': upload_domain, |
128
|
|
|
'downloaddomain': download_domain, |
129
|
|
|
} |
130
|
|
|
) |
131
|
|
|
|
132
|
10 |
|
def bind_tester(self, wechat_id): |
133
|
|
|
""" |
134
|
|
|
绑定微信用户成为小程序体验者 |
135
|
|
|
详情请参考 |
136
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140588_nVUgx |
137
|
|
|
|
138
|
|
|
:param wechat_id: 微信号 |
139
|
|
|
""" |
140
|
|
|
return self._post( |
141
|
|
|
'wxa/bind_tester', |
142
|
|
|
data={ |
143
|
|
|
'wechatid': wechat_id, |
144
|
|
|
} |
145
|
|
|
) |
146
|
|
|
|
147
|
10 |
|
def unbind_tester(self, wechat_id): |
148
|
|
|
""" |
149
|
|
|
解除绑定小程序的体验者 |
150
|
|
|
详情请参考 |
151
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140588_nVUgx |
152
|
|
|
|
153
|
|
|
:param wechat_id: 微信号 |
154
|
|
|
""" |
155
|
|
|
return self._post( |
156
|
|
|
'wxa/unbind_tester', |
157
|
|
|
data={ |
158
|
|
|
'wechatid': wechat_id, |
159
|
|
|
} |
160
|
|
|
) |
161
|
|
|
|
162
|
10 |
|
def commit(self, template_id, ext_json, version, description): |
163
|
|
|
""" |
164
|
|
|
为授权的小程序账号上传小程序代码 |
165
|
|
|
详情请参考 |
166
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4 |
167
|
|
|
|
168
|
|
|
:param template_id: 代码库中的代码模板 ID |
169
|
|
|
:param ext_json: 第三方自定义的配置 |
170
|
|
|
:param version: 代码版本号,开发者可自定义 |
171
|
|
|
:param description: 代码描述,开发者可自定义 |
172
|
|
|
""" |
173
|
|
|
return self._post( |
174
|
|
|
'wxa/commit', |
175
|
|
|
data={ |
176
|
|
|
'template_id': template_id, |
177
|
|
|
'ext_json': ext_json, |
178
|
|
|
'user_version': version, |
179
|
|
|
'user_desc': description, |
180
|
|
|
}, |
181
|
|
|
) |
182
|
|
|
|
183
|
10 |
|
def get_qrcode(self): |
184
|
|
|
""" |
185
|
|
|
获取体验小程序的体验二维码 |
186
|
|
|
返回 Response 类型,header 中带有 Content-Type 与 Content-disposition 类型 |
187
|
|
|
详情请参考 |
188
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4 |
189
|
|
|
|
190
|
|
|
:rtype: requests.Response |
191
|
|
|
""" |
192
|
|
|
return self._get('wxa/get_qrcode') |
193
|
|
|
|
194
|
10 |
|
def get_category(self): |
195
|
|
|
""" |
196
|
|
|
获取授权小程序账号的可选类目 |
197
|
|
|
详情请参考 |
198
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4 |
199
|
|
|
|
200
|
|
|
:rtype: list[dict] |
201
|
|
|
""" |
202
|
|
|
return self._get( |
203
|
|
|
'wxa/get_category', |
204
|
|
|
result_processor=lambda x: x['category_list'], |
205
|
|
|
) |
206
|
|
|
|
207
|
10 |
|
def get_page(self): |
208
|
|
|
""" |
209
|
|
|
获取小程序的第三方提交代码的页面配置 |
210
|
|
|
详情请参考 |
211
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4 |
212
|
|
|
|
213
|
|
|
:rtype: list |
214
|
|
|
""" |
215
|
|
|
return self._get( |
216
|
|
|
'wxa/get_page', |
217
|
|
|
result_processor=lambda x: x['page_list'], |
218
|
|
|
) |
219
|
|
|
|
220
|
10 |
|
def submit_audit(self, data): |
221
|
|
|
""" |
222
|
|
|
将第三方提交的代码包提交审核 |
223
|
|
|
详情请参考 |
224
|
|
|
https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/code/submit_audit.html |
225
|
|
|
""" |
226
|
|
|
return self._post( |
227
|
|
|
'wxa/submit_audit', |
228
|
|
|
data=data |
229
|
|
|
) |
230
|
|
|
|
231
|
10 |
|
def undo_code_audit(self): |
232
|
|
|
""" |
233
|
|
|
调用本接口可以撤回当前的代码审核单 |
234
|
|
|
注意: 单个帐号每天审核撤回次数最多不超过 1 次,一个月不超过 10 次。 |
235
|
|
|
https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/code/undocodeaudit.html |
236
|
|
|
""" |
237
|
|
|
return self._get( |
238
|
|
|
'wxa/undocodeaudit' |
239
|
|
|
) |
240
|
|
|
|
241
|
10 |
|
def revert_code_release(self): |
242
|
|
|
""" |
243
|
|
|
调用本接口可以将小程序的线上版本进行回退 |
244
|
|
|
注意: |
245
|
|
|
1. 如果没有上一个线上版本,将无法回退 |
246
|
|
|
2. 只能向上回退一个版本,即当前版本回退后,不能再调用版本回退接口 |
247
|
|
|
https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/code/revertcoderelease.html |
248
|
|
|
""" |
249
|
|
|
return self._get( |
250
|
|
|
'wxa/revertcoderelease' |
251
|
|
|
) |
252
|
|
|
|
253
|
10 |
|
def get_audit_status(self, auditid): |
254
|
|
|
""" |
255
|
|
|
查询某个指定版本的审核状态 |
256
|
|
|
详情请参考 |
257
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4 |
258
|
|
|
|
259
|
|
|
:param auditid: 审核编号 |
260
|
|
|
:type auditid: int |
261
|
|
|
:return: 一个包含 status, reason 的 dict。status 0为审核成功,1为审核失败,2为审核中。 |
262
|
|
|
""" |
263
|
|
|
return self._post( |
264
|
|
|
'wxa/get_auditstatus', |
265
|
|
|
data={ |
266
|
|
|
'auditid': auditid, |
267
|
|
|
}, |
268
|
|
|
) |
269
|
|
|
|
270
|
10 |
|
def get_latest_audit_status(self): |
271
|
|
|
""" |
272
|
|
|
查询最近一次提交的审核状态 |
273
|
|
|
详情请参考 |
274
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4 |
275
|
|
|
|
276
|
|
|
:return: 一个包含 status, reason, auditid 的 dict。status 0为审核成功,1为审核失败,2为审核中。 |
277
|
|
|
""" |
278
|
|
|
return self._get( |
279
|
|
|
'wxa/get_latest_auditstatus' |
280
|
|
|
) |
281
|
|
|
|
282
|
10 |
|
def release(self): |
283
|
|
|
""" |
284
|
|
|
发布已通过审核的小程序 |
285
|
|
|
详情请参考 |
286
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4 |
287
|
|
|
""" |
288
|
|
|
return self._post( |
289
|
|
|
'wxa/release', |
290
|
|
|
data={}, |
291
|
|
|
) |
292
|
|
|
|
293
|
10 |
|
def change_visit_status(self, close=False): |
294
|
|
|
""" |
295
|
|
|
修改小程序线上代码的可见状态 |
296
|
|
|
详情请参考 |
297
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4 |
298
|
|
|
|
299
|
|
|
:param close: close 为 True 时会关闭小程序线上代码的可见状态。 |
300
|
|
|
:type close: bool |
301
|
|
|
""" |
302
|
|
|
return self._post( |
303
|
|
|
'wxa/change_visitstatus', |
304
|
|
|
data={ |
305
|
|
|
'action': 'close' if close else 'open', |
306
|
|
|
}, |
307
|
|
|
) |
308
|
|
|
|
309
|
10 |
|
def list_library_templates(self, offset=0, count=20): |
310
|
|
|
""" |
311
|
|
|
获取小程序模板库里,所有模板的ID与标题 |
312
|
|
|
详情请参考 |
313
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR |
314
|
|
|
|
315
|
|
|
:param offset: 用于分页,表示起始量,最小值为0 |
316
|
|
|
:type offset: int |
317
|
|
|
:param count: 用于分页,表示拉取数量,最大值为20 |
318
|
|
|
:type count: int |
319
|
|
|
:return: 带有 total_count 与 list 的数据 |
320
|
|
|
:rtype: dict |
321
|
|
|
""" |
322
|
|
|
return self._post( |
323
|
|
|
'cgi-bin/wxopen/template/library/list', |
324
|
|
|
data={ |
325
|
|
|
'offset': offset, |
326
|
|
|
'count': count, |
327
|
|
|
}, |
328
|
|
|
) |
329
|
|
|
|
330
|
10 |
|
def get_library_template(self, template_short_id): |
331
|
|
|
""" |
332
|
|
|
获取小程序模板库里,某个模板的详细信息 |
333
|
|
|
详情请参考 |
334
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR |
335
|
|
|
|
336
|
|
|
:param template_short_id: 模板标题ID |
337
|
|
|
:rtype: dict |
338
|
|
|
""" |
339
|
|
|
return self._post( |
340
|
|
|
'cgi-bin/wxopen/template/library/get', |
341
|
|
|
data={ |
342
|
|
|
'id': template_short_id, |
343
|
|
|
}, |
344
|
|
|
) |
345
|
|
|
|
346
|
10 |
|
def list_templates(self, offset=0, count=20): |
347
|
|
|
""" |
348
|
|
|
获取本账号内所有模板 |
349
|
|
|
详情请参考 |
350
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR |
351
|
|
|
|
352
|
|
|
:param offset: 用于分页,表示起始量,最小值为0 |
353
|
|
|
:type offset: int |
354
|
|
|
:param count: 用于分页,表示拉取数量,最大值为20 |
355
|
|
|
:type count: int |
356
|
|
|
:return: 模板列表 |
357
|
|
|
:rtype: list[dict] |
358
|
|
|
""" |
359
|
|
|
return self._post( |
360
|
|
|
'cgi-bin/wxopen/template/list', |
361
|
|
|
data={ |
362
|
|
|
'offset': offset, |
363
|
|
|
'count': count, |
364
|
|
|
}, |
365
|
|
|
result_processor=lambda x: x['list'], |
366
|
|
|
) |
367
|
|
|
|
368
|
10 |
|
def add_template(self, template_short_id, keyword_id_list): |
369
|
|
|
""" |
370
|
|
|
组合模板,并将其添加至账号下的模板列表里 |
371
|
|
|
详情请参考 |
372
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR |
373
|
|
|
|
374
|
|
|
:param template_short_id: 模板标题ID |
375
|
|
|
:param keyword_id_list: 按照顺序排列的模板关键词列表,最多10个 |
376
|
|
|
:type keyword_id_list: list[int] |
377
|
|
|
:return: 模板ID |
378
|
|
|
""" |
379
|
|
|
return self._post( |
380
|
|
|
'cgi-bin/wxopen/template/add', |
381
|
|
|
data={ |
382
|
|
|
'id': template_short_id, |
383
|
|
|
'keyword_id_list': keyword_id_list, |
384
|
|
|
}, |
385
|
|
|
result_processor=lambda x: x['template_id'], |
386
|
|
|
) |
387
|
|
|
|
388
|
10 |
|
def del_template(self, template_id): |
389
|
|
|
""" |
390
|
|
|
删除本账号内某个模板 |
391
|
|
|
详情请参考 |
392
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1500465446_j4CgR |
393
|
|
|
|
394
|
|
|
:param template_id: 模板ID |
395
|
|
|
""" |
396
|
|
|
return self._post( |
397
|
|
|
'cgi-bin/wxopen/template/del', |
398
|
|
|
data={ |
399
|
|
|
'template_id': template_id, |
400
|
|
|
}, |
401
|
|
|
) |
402
|
|
|
|
403
|
10 |
|
def create_open(self, appid): |
404
|
|
|
""" |
405
|
|
|
创建开放平台账号,并绑定公众号/小程序 |
406
|
|
|
详情请参考 |
407
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1498704199_1bcax |
408
|
|
|
|
409
|
|
|
:param appid: 授权公众号或小程序的 appid |
410
|
|
|
:return: 开放平台的 appid |
411
|
|
|
""" |
412
|
|
|
return self._post( |
413
|
|
|
'cgi-bin/open/create', |
414
|
|
|
data={ |
415
|
|
|
'appid': appid, |
416
|
|
|
}, |
417
|
|
|
result_processor=lambda x: x['open_appid'], |
418
|
|
|
) |
419
|
|
|
|
420
|
10 |
|
def get_open(self, appid): |
421
|
|
|
""" |
422
|
|
|
获取公众号/小程序所绑定的开放平台账号 |
423
|
|
|
详情请参考 |
424
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1498704199_1bcax |
425
|
|
|
|
426
|
|
|
:param appid: 授权公众号或小程序的 appid |
427
|
|
|
:return: 开放平台的 appid |
428
|
|
|
""" |
429
|
|
|
return self._post( |
430
|
|
|
'cgi-bin/open/get', |
431
|
|
|
data={ |
432
|
|
|
'appid': appid, |
433
|
|
|
}, |
434
|
|
|
result_processor=lambda x: x['open_appid'], |
435
|
|
|
) |
436
|
|
|
|
437
|
10 |
|
def bind_open(self, appid, open_appid): |
438
|
|
|
""" |
439
|
|
|
将公众号/小程序绑定到开放平台帐号下 |
440
|
|
|
详情请参考 |
441
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1498704199_1bcax |
442
|
|
|
|
443
|
|
|
:param appid: 授权公众号或小程序的 appid |
444
|
|
|
:param open_appid: 开放平台帐号 appid |
445
|
|
|
""" |
446
|
|
|
return self._post( |
447
|
|
|
'cgi-bin/open/bind', |
448
|
|
|
data={ |
449
|
|
|
'appid': appid, |
450
|
|
|
'open_appid': open_appid, |
451
|
|
|
} |
452
|
|
|
) |
453
|
|
|
|
454
|
10 |
|
def unbind_open(self, appid, open_appid): |
455
|
|
|
""" |
456
|
|
|
将公众号/小程序绑定到开放平台帐号下 |
457
|
|
|
详情请参考 |
458
|
|
|
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1498704199_1bcax |
459
|
|
|
|
460
|
|
|
:param appid: 授权公众号或小程序的 appid |
461
|
|
|
:param open_appid: 开放平台帐号 appid |
462
|
|
|
""" |
463
|
|
|
return self._post( |
464
|
|
|
'cgi-bin/open/unbind', |
465
|
|
|
data={ |
466
|
|
|
'appid': appid, |
467
|
|
|
'open_appid': open_appid, |
468
|
|
|
} |
469
|
|
|
) |
470
|
|
|
|
471
|
10 |
|
def code_to_session(self, js_code): |
472
|
|
|
""" |
473
|
|
|
登录凭证校验。通过 wx.login() 接口获得临时登录凭证 code 后传到开发者服务器调用此接口完成登录流程。更多使用方法详见 小程序登录 |
474
|
|
|
详情请参考 |
475
|
|
|
https://developers.weixin.qq.com/miniprogram/dev/api/code2Session.html |
476
|
|
|
|
477
|
|
|
:param js_code: |
478
|
|
|
:return: |
479
|
|
|
""" |
480
|
10 |
|
return self._get( |
481
|
|
|
'sns/jscode2session', |
482
|
|
|
params={ |
483
|
|
|
'appid': self.appid, |
484
|
|
|
'secret': self.secret, |
485
|
|
|
'js_code': js_code, |
486
|
|
|
'grant_type': 'authorization_code' |
487
|
|
|
} |
488
|
|
|
) |
489
|
|
|
|
490
|
10 |
|
def check_image_security(self, media): |
491
|
|
|
""" |
492
|
|
|
校验一张图片是否含有违法违规内容。 |
493
|
|
|
详情请参考 |
494
|
|
|
https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.imgSecCheck.html |
495
|
|
|
|
496
|
|
|
:param media: 要检测的图片文件,格式支持PNG、JPEG、JPG、GIF,图片尺寸不超过 750px x 1334px |
497
|
|
|
:return: |
498
|
|
|
""" |
499
|
|
|
return self._post( |
500
|
|
|
'wxa/img_sec_check', |
501
|
|
|
files={ |
502
|
|
|
'media': media, |
503
|
|
|
} |
504
|
|
|
) |
505
|
|
|
|
506
|
10 |
|
def check_text_security(self, content): |
507
|
|
|
""" |
508
|
|
|
检查一段文本是否含有违法违规内容。 |
509
|
|
|
详情请参考 |
510
|
|
|
https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.msgSecCheck.html |
511
|
|
|
|
512
|
|
|
:param content: 要检测的文本内容,长度不超过 500KB |
513
|
|
|
:return: |
514
|
|
|
""" |
515
|
|
|
return self._post( |
516
|
|
|
'wxa/msg_sec_check', |
517
|
|
|
data={ |
518
|
|
|
'content': content, |
519
|
|
|
} |
520
|
|
|
) |
521
|
|
|
|
522
|
10 |
|
def speed_up_audit(self, auditid): |
523
|
|
|
""" |
524
|
|
|
加急审核申请 |
525
|
|
|
有加急次数的第三方可以通过该接口,对已经提审的小程序进行加急操作,加急后的小程序预计2-12小时内审完。 |
526
|
|
|
https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/code/speedup_audit.html |
527
|
|
|
""" |
528
|
|
|
return self._post( |
529
|
|
|
'wxa/speedupaudit', |
530
|
|
|
data={ |
531
|
|
|
"auditid": auditid |
532
|
|
|
} |
533
|
|
|
) |
534
|
|
|
|
535
|
10 |
|
def query_quota(self): |
536
|
|
|
""" |
537
|
|
|
查询服务商的当月提审限额(quota)和加急次数 |
538
|
|
|
服务商可以调用该接口,查询当月平台分配的提审限额和剩余可提审次数,以及当月分配的审核加急次数和剩余加急次数。(所有旗下小程序共用该额度) |
539
|
|
|
https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/code/query_quota.html |
540
|
|
|
""" |
541
|
|
|
return self._get('wxa/queryquota') |
542
|
|
|
|
543
|
|
|
def get_paid_unionid(self, openid, transaction_id=None, mch_id=None, out_trade_no=None): |
544
|
|
|
""" |
545
|
|
|
用户支付完成后,获取该用户的 UnionId,无需用户授权。 |
546
|
|
|
|
547
|
|
|
详情请参考 |
548
|
|
|
https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/user-info/auth.getPaidUnionId.html |
549
|
|
|
|
550
|
|
|
:param openid: 支付用户唯一标识 |
551
|
|
|
:param transaction_id: 微信支付订单号,可选 |
552
|
|
|
:param mch_id: 微信支付分配的商户号,和商户订单号配合使用,可选 |
553
|
|
|
:param out_trade_no: 微信支付商户订单号,和商户号配合使用 |
554
|
|
|
:return: 用户唯一标识 unionid |
555
|
|
|
""" |
556
|
|
|
return self._get( |
557
|
|
|
'wxa/getpaidunionid', |
558
|
|
|
params={ |
559
|
|
|
'openid': openid, |
560
|
|
|
'transaction_id': transaction_id, |
561
|
|
|
'mch_id': mch_id, |
562
|
|
|
'out_trade_no': out_trade_no, |
563
|
|
|
}, |
564
|
|
|
result_processor=lambda x: x['unionid'] |
565
|
|
|
) |
566
|
|
|
|