APPID = 'xxxxxxxxx'
APPSECRET = 'xxxxxxxxxxxxxx'
response = requests.get(
'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}'.format(APPID, APPSECRET)
)
ACCESS_TOKEN = response.json()
DD = ACCESS_TOKEN.get('access_token')
result = requests.post(url=r'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={}'.format(DD), headers = {'Content-Type': 'application/json','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'}, data=
json.dumps({
"touser": "需要发送的用户的openid",
"template_id": "消息模板id",
"url": "https://weixin.qq.com/download",
下面的参数一定要按照自己公众号申请的模板的字段名称填写比如:"thing2","thing4"。
"data": {
"thing2": {
"value": "xxxxx会议通知"
},
"thing4": {
"value": "xxx地址"
},
"time6": {
"value": "2024年9月22日"
},
"time11": {
"value": "2014年8月22日"
},
"thing7": {
"value": "张三"
}
}
}))
标签:qq,python,json,value,token,推送,com,模板,亲测 From: https://www.cnblogs.com/yuanyongsheng/p/18206745