概述
#!/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 && 微信企业号发送消息脚本所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复