复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55#!/bin/bash function Send_wechat(){ local Corpid="wwe0c2d77a28f790cx7" local Corpsecret="xGNx-afxsJ29xQQxQhJLxx_-i1nxpOMm4O7CoHsxgN0va0AXzW4" local Jna_Secret="GNx-afsJx29QQQhJL_-i1nxpOMm4O7CoHsgNx0va0AXzW4" local Access_token_file="/tmp/access_token" local Agentid='10001' local Gettoken_url="https://qyapi.weixin.qq.com/cgi-bin/gettoken" local Message_send_url="https://qyapi.weixin.qq.com/cgi-bin/message/send" if [ -f ${Access_token_file} ];then local Access_token=`cat ${Access_token_file} |xargs echo |awk -F"[ ,:]" '{print $6}'` else local Access_token=`` fi function Get_access_token(){ /usr/bin/curl ${Gettoken_url}?corpid=${Corpid}&corpsecret=${Corpsecret} -o ${Access_token_file} echo `date +%s` >> ${Access_token_file} Access_token=`cat ${Access_token_file} |xargs echo |awk -F"[ ,:]" '{print $6}'` echo ${Access_token} } function Check_access_token(){ Access_token_time=`awk -F"[ ,:}]" '{print $9}' ${Access_token_file}` local Now_time=`date +%s` if [ ${Access_token} == "" ] ;then Get_access_token fi if [ "${Access_token_time}"x != ""x ];then Check_time=$((${Now_time}-${Access_token_time})) fi if [ "${Access_token_time}"x == ""x ]; then Get_access_token fi if [ ! "${Check_time}"x == ""x ] ;then if [ ${Check_time} -ge 7200 ] ;then Get_access_token fi fi } Check_access_token Data="{ "touser" : "@all", "toparty" : "PartyID1|PartyID2", "totag" : "TagID1 | TagID2", "msgtype" : "text", "agentid" : ${Agentid}, "text" : { "content" : "$1"}, "safe":0 }" curl -H "Content-Type:application/json" -X POST --data "${Data}" ${Message_send_url}?access_token=${Access_token} }
最后
以上就是兴奋大碗最近收集整理的关于Linux && 微信企业号发送消息脚本的全部内容,更多相关Linux内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复