import requests
response = requests.get("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=xxxx")
attt = response.json()['access_token']
# 请求url
url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token="+str(attt)
# 请求参数
payload = {
"touser" : "JohnZhang|XiaoCui",
"msgtype" : "text",
"agentid" : 1000003,
"text" : {
"content" : "I am Minions"
},
"safe":0,
"enable_id_trans": 0,
"enable_duplicate_check": 0,
"duplicate_check_interval": 1800
}
# form表单形式,参数用data
res = requests.post(url, json=payload)
print(res.text)
写一个简单的Python程序,实现通过企业微信发送通知。