一.企业微信注册地址:
https://work.weixin.qq.com/?from=openApi
二.请求格式
1.获取token的方法
curl -s 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$corpsecret'|awk -F """ '{print $10}'
2.正常请求格式:
(1)需要token和成员账号,部门ID
curl -s -m 300 -H "Context-type:application/json" -X 'POST' 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$access_token' -d '{ "touser": "XueFeng", "toparty": "1","msgtype": "text","agentid": "1000002","text": {"content": "'获取时间:20190813'
'内网地址:1.0.0.0'
'主机名称:product-zabbix'
"},"safe":"0"}'
(2)部门ID不是必须的,去掉后仍然可以发送报警,但是必须制定成员账号,token有时效性
curl -s -m 300 -H "Context-type:application/json" -X 'POST' 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$access_token' -d '{ "touser": "XueFeng","msgtype": "text","agentid": "1000002","text": {"content": "'获取时间:20190813'
'内网地址:1.0.0.0'
'主机名称:product-zabbix'
"},"safe":"0"}'
三.相关参考
API测试地址:https://work.weixin.qq.com/api/devtools/devtool.php
产看接口参数的地址:https://work.weixin.qq.com/api/doc#90000/90135/90250/文本消息
查看返回错误码的地址:https://work.weixin.qq.com/api/doc#90002/90156/90475