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 趙本帥測試發消息