shell转发短信给微信/通过shell发送信息给企业微信
😂 这篇文章最后更新于1323天前,您需要注意相关的内容是否还可用。
通用shell代码如下(需要自己替换企业ID,应用ID/密钥与信息内容):
#!/bin/sh #link https://dongfg.com/uncategorized/message-push/ CORP_ID="企业ID" CORP_AgentId="应用ID" CORP_SECRET="应用密钥" # 换行 \r\n 或 <br\> 空格 \r sms=联系人1:[sms_name]号码:[sms_number]日期:[year]/[month_digit]/[dayofmonth]时间:[hour]:[minute]:[second]剩余电量:[battery]内容:[sms_message] main() { access_token=$(curl -k -s "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CORP_ID&corpsecret=$CORP_SECRET") TOKEN=$(echo $access_token | sed "s/.*\"access_token\":\"\([^\"]*\).*/\1/g") curl -k -X POST -d '{ "touser": "@all", "msgtype": "text", "agentid": '$CORP_AgentId', "text": { "content": "'$sms'" }, "safe": 0 }' "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$TOKEN" } main $sms
sms=后为要发送信息内容,同样也可以与MacroDroid/Tasker结合作为转发手机短信的通道。
只是MacroDroid使用可能要将以上换行全替换成”\n“,具体期待你的测试。
以上代码来源自网络。
留言评论
暂无留言