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 '{
'
printf '"touser": "'$UserID'",
'
printf '"toparty": "'$PartyID'",
'
printf '"msgtype": "text",
'
printf '"agentid": "'$AppID'",
'
printf '"text": {
'
printf '"content": "'$Msg'"
'
printf '},
'
printf '"safe":"0"
'
printf '}
'
}
#body $1
curl --data-ascii "$(body $1)" $PURL
printf '
'
echo "over!"
5. 可以进行测试验证.
./sendt "yourname|magic" 1 1000002 赵本帅测试发消息