1 Star 0 Fork 0

wangpf / script

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
qywx_msg.sh 886 Bytes
Copy Edit Web IDE Raw Blame History
wangpf authored 2021-08-24 16:56 . 添加企业微信消息推送
#!/bin/bash
#要发送的消息
msg=$1
content=$msg
#企业id
qywx_corpid=
#企业应用的secret
qywx_corpsecret=
#指定接收消息的成员
touser=
#指定接收消息的部门
toparty=
#企业应用的id
agentid=1000004
response_token="$(curl -s "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$qywx_corpid&corpsecret=$qywx_corpsecret")"
other_token="{\"errcode\":0,\"errmsg\":\"ok\",\"access_token\":\""
other_token2="\",\"expires_in\":7200}"
response_token=${response_token/$other_token/}
access_token=${response_token/$other_token2/}
msg_body="{\"touser\":\"$touser\",\"toparty\":\"$toparty\",\"msgtype\":\"text\",\"agentid\":$agentid,\"text\":{\"content\":\"$content\"}}"
req_send_msg_url=https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$access_token
req_msg=$(curl -s -H "Content-Type: application/json" -X POST -d $msg_body $req_send_msg_url)
echo $req_msg

Comment ( 0 )

Sign in to post a comment

Shell
1
https://gitee.com/NealC/script.git
git@gitee.com:NealC/script.git
NealC
script
script
master

Search