|
#!/bin/bash #set
-x CorpID
="xxxxx" Secret
="xxxxx" GURL
="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CorpID&corpsecret=$Secret" Token
=$(/usr/bin/curl -s -G $GURL |awk -F\":'{print $4}'|awk -F\" '{print $2}') echo $Token
PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Token"
UserID=$1
PartyID=2
agentid=1
Msg=$(echo "$@"|cut -d" "-f1-)
message(){
printf '{\n'
printf '\t"touser": "'"$UserID"\"",\n"
printf '\t"toparty": "'"$PartyID"\"",\n"
printf '\t"msgtype": "text",\n'
printf '\t"agentid": "'"$agentid"\"",\n"
printf '\t"text": {\n'
printf '\t\t"content": "'"$Msg"\""\n"
printf '\t},\n'
printf '\t"safe":"0"\n'
printf '}\n'
}
/usr/bin/curl --data-ascii "$(message $1 $2 $3)" $PURL |
|
|