1. Study From
https://www.cnblogs.com/elvi/p/11444388.html
2. 申请或者使用已经有的企业微信.
首先是获取一下企业id
方法如图:
3. 创建一个应用, 并且获取app的secret
然后能够看到相应的密钥
4. 编写一个shell 脚本发送消息, 注意 我这里还没搞明白 如何给群发
CropID='ww7a1xxxxxxxxa986'
Secret='lI9QYb_8xxxxxxxxxxxxxxxxxxZYVIE'
GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CropID&corpsecret=$Secret"
Gtoken=$(/usr/bin/curl -s -G $GURL | awk -F \" '{print $10}')
PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Gtoken"
UserID=$1
PartyID=$2
AppID=$3
Msg=$4
function body() {
printf '{\n'
printf '\t"touser": "'$UserID'",\n'
printf '\t"toparty": "'$PartyID'",\n'
printf '\t"msgtype": "text",\n'
printf '\t"agentid": "'$AppID'",\n'
printf '\t"text": {\n'
printf '\t\t"content": "'$Msg'"\n'
printf '\t},\n'
printf '\t"safe":"0"\n'
printf '}\n'
}
#body $1
curl --data-ascii "$(body $1)" $PURL
printf '\n'
echo "over!"
5. 进行测试验证即可.
./sendt "yourname|magic" 1 1000002 赵本帅测试发消息