tyy.jpg

#!/bin/bash

#通讯录可获取,多个人员之间使用空格分隔
user="123456"
#企业微信ID
corpid="ww2222"
#应用秘钥
corpsecret="ddddddddddddddddddddddddddddddddddddd"
#企业应用ID
agentld=1000002

msg=$1
A=`curl -s https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid\&corpsecret=$corpsecret`
#解析json格式 并获取access_token值
token=`echo $A | jq -c '.access_token'`
#去除双引号
token=${token#*\"}
token=${token%*\"}
URL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$token"

for I in $user;do
    JSON="{\"touser\": \"$I\",\"msgtype\": \"text\",\"agentid\": \"$agentld\",\"text\": {\"content\": \"$msg\"},\"safe\":0 }"
    curl -d "$JSON" "$URL" >/dev/null 2>&1
done

exit 0

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code