一、代码
#!/usr/local/python3.6.2/bin/python3
# -*- coding: utf-8 -*-
import requests
import json
import sys
import os
headers = {'Content-Type': 'application/json;charset=utf-8'}
api_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6120ddf6-0ef4-43fa-91c6-001ab5f383f1" #机器人webhook地址
def msg(text):
json_text= {
"msgtype": "text",
"text": {
"content": text
},
}
print(requests.post(api_url,json.dumps(json_text),headers=headers).content)
if __name__ == '__main__':
text = sys.argv[1]
msg(text)
脚本测试:python3 + 脚本+‘消息’
二、媒体参数