• 微信企业号 发送信息 shell


    微信企业号发送信息shell

    可作为shell函数模块调用,用于微信通知、jenkins发版微信通知等等
    微信API官方文档 https://work.weixin.qq.com/api/doc#90002/90151/90854

    #!/bin/bash
    # wechat.send.sh
    # 微信企业号发送信息 shell
    # blog https://www.cnblogs.com/elvi/p/11444388.html
    
    ##############################
    
    function sendmsg() {
    
    CorpID="wwe518*企业微信账号唯一ID"
    Secret="自定义应用的密钥"
    AgentId=1000004  #应用id
    
    Url="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CorpID&corpsecret=$Secret"
    Gtoken=$(curl -s -G $Url|awk -F" '{print $10}')
    PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Gtoken"
    
    [ `echo $Gtoken |wc -L` -gt 100 ] || { echo "get token error !";exit 1; }
    
    curl -s --data-ascii '{
    "toparty": "'"$1"'",
    "msgtype": "text",
    "agentid": "'"$AgentId"'",
    "text": {"content": "'"$2"'"}
    }' $PURL &>/tmp/wechat.log
    
    if [ `grep "errmsg.*ok" /tmp/wechat.log |wc -l` -ne 1 ];then
        echo 'send error !'
        cat /tmp/wechat.log
        exit 1
    fi
    
    }
    
    ##############################
    #测试 sendmsg
    
    #内容
    msg="@警告
    主机:$(hostname)
    信息:Node test
    时间:$(date +"%F %T")
    "
    
    #  发送 "部门id" "内容"
    sendmsg "3" "$msg"
    
    ##############################
    
    
  • 相关阅读:
    Math.pow
    css3正方体
    制作一个百度换肤效果
    排他思想
    js栈和堆的区别
    js创建对象的几种方式(工厂模式、构造函数模式、原型模式)
    短网址
    this
    作用域
    JS 函数基础
  • 原文地址:https://www.cnblogs.com/elvi/p/11444388.html
Copyright © 2020-2023  润新知