• SQL Server通过钉钉机器人直接发送消息


    RT

    /**
    
    启用 Ole Automation Procedures 选项
    exec sp_configure 'show advanced options',1;
    go
    reconfigure;
    go
    sp_configure 'Ole Automation Procedures',1;
    go
    reconfigure;
    go
    */
    declare @PostData nVARCHAR(max) = '' , @ResponseText VARCHAR(max) = '' 
    DECLARE @ServiceUrl AS VARCHAR(1000) 
    set @ServiceUrl = N'https://oapi.dingtalk.com/robot/send?access_token=*****0'
    set @PostData = N'{"msgtype": "markdown", "markdown": { 
    "title":"机器人", 
    "text": "
    ### 通知
     
    来自**机器人**的通知
    " } }' 
    
    DECLARE @Object AS INT ,
    @status INT ,
    @returnText AS VARCHAR(8000) ,
    @HttpStatus VARCHAR(200) ,
    @HttpMethod VARCHAR(20) = 'post'
    
    
    EXEC @status = sp_OACreate 'Msxml2.ServerXMLHTTP.3.0', @Object OUT;
    
    EXEC @status = sp_OAMethod @Object, 'open', NULL, @HttpMethod, @ServiceUrl, 'false'
    
    EXEC @status = sys.sp_OAMethod @Object, 'setRequestHeader', NULL, 'Content-Type', 'application/json; charset=UTF-8'
    
    EXEC @status = sp_OAMethod @Object, 'send', NULL, @PostData
    
    EXEC @status = sys.sp_OAGetProperty @Object, 'Status', @HttpStatus OUT;
    
    EXEC @status = sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
    
    EXEC @status = sp_OADestroy @Object
    print @ResponseText
    
     
    
     
  • 相关阅读:
    团队展示
    平衡二叉树AVLTree
    红黑树原理
    日本楼市崩盘始末
    池化
    Spring配置多数据源
    关于C语言指针几个容易混淆的概念
    .net core 部署 Docker 所遇到的几个问题
    自定义类加载器也是无法实现加载java.lang.String的
    jquery轻量级数字动画插件jquery.countup.js
  • 原文地址:https://www.cnblogs.com/jerron/p/6501147.html
Copyright © 2020-2023  润新知