Last active
January 12, 2022 11:57
-
-
Save 1oo1/d3f81ff501abbdbe571cabd2cc9c49d2 to your computer and use it in GitHub Desktop.
小程序参数二维码生成
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests as rq | |
import json | |
# 获取 access_token | |
url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=YOUR_APP_ID&secret=YOUR_SECRET' | |
res = rq.get(url) | |
json = res.json() | |
access_token = json['access_token'] | |
# print(access_token) | |
# 生成带页面参数的二维码 | |
qrcode_url = 'https://api.weixin.qq.com/wxa/getwxacode?access_token=%s' % access_token | |
r = rq.post(qrcode_url, data=json.dumps({'path': 'pages/index/index?channel=?channel=mychannel-wx'})) | |
path = 'qrcode.png' | |
with open(path, 'wb') as f: | |
f.write(r.content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment