1. Study From 

https://www.cnblogs.com/elvi/p/11444388.html

2. 申请或者使用已经有的企业微信.

首先是获取一下企业id

方法如图:

Bash 脚本发送消息到企业微信的办法

 

 3. 创建一个应用, 并且获取app的secret

Bash 脚本发送消息到企业微信的办法

 

 然后能够看到相应的密钥

Bash 脚本发送消息到企业微信的办法

 

 

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. 进行测试验证即可. 

 Bash 脚本发送消息到企业微信的办法

 

 ./sendt "yourname|magic"  1  1000002 赵本帅测试发消息

 

相关文章:

  • 2021-05-18
  • 2021-12-20
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-02-04
  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2022-01-20
  • 2021-10-09
  • 2021-09-21
  • 2021-11-18
相关资源
相似解决方案