# 这是一个示例 Python 脚本。
# 按 Shift+F10 执行或将其替换为您的代码。
# 按 双击 Shift 在所有地方搜索类、文件、工具窗口、操作和设置。
import requests
import json
def get_access_token():
APPID="wx0000"
APPSECRET="***********"
url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}".format(APPID,APPSECRET)
res = requests.get(url)
result = res.json()
return result["access_token"]
def get_urlscheme(ACCESS_TOKEN):
url = "https://api.weixin.qq.com/wxa/generatescheme?access_token={}".format(ACCESS_TOKEN)
#print(url)
data={ # // path跳转到的小程序目标页面,query跳转需要携带参数,在目标页面onload里面接收options里面,其他参数固定,获取看文档了解
'jump_wxa': {
'path': "/pages/index/index",
'query': "",
'env_version': "trial" #// 正式版为"release",体验版为"trial",开发版为"develop"
},
'is_expire': True,
'expire_type': 1,
'expire_interval': 1
}
header={
"Content-type":"application/json; charset=utf-8"
}
print(json.dumps(data))
res = requests.post(url,headers=header,data=json.dumps(data))
print(res.text)
token = get_access_token()
#print(token)
get_urlscheme(token)
05-23
1082
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-08
1318
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-07
1798
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)