|
@@ -246,6 +246,27 @@ class WeChat(object):
|
|
|
destination.write(result.content)
|
|
|
return filename
|
|
|
|
|
|
+ @staticmethod
|
|
|
+ def getDeviceCode(access_token, page, device_id):
|
|
|
+ '''获取设备二维码'''
|
|
|
+ url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={}'.format(access_token)
|
|
|
+ data = {"scene": "device_id={}".format(device_id),
|
|
|
+ "width": 1280,
|
|
|
+ "line_color": {"r": 43, "g": 162, "b": 69}, # 自定义颜色
|
|
|
+ "is_hyaline": True}
|
|
|
+ result = requests.post(url, json=data)
|
|
|
+
|
|
|
+ upload_path = PathAndRename("device/")
|
|
|
+ filename = "%s%s.png" % (
|
|
|
+ upload_path.path,
|
|
|
+ device_id,
|
|
|
+ )
|
|
|
+ filename = filename.lower()
|
|
|
+ full_filename = "%s%s" % (settings.MEDIA_ROOT, filename)
|
|
|
+ with open(full_filename, 'wb') as destination:
|
|
|
+ destination.write(result.content)
|
|
|
+ return filename
|
|
|
+
|
|
|
@staticmethod
|
|
|
def releaseCode(access_token):
|
|
|
'''已审核代码发布'''
|