首页 > 数据库技术 > 详细

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

时间:2017-03-04 14:25:42      阅读:1891      评论:0      收藏:0      [点我收藏+]

 

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 = Nhttps://oapi.dingtalk.com/robot/send?access_token=*****0
set @PostData = N{"msgtype": "markdown", "markdown": { 
"title":"机器人", 
"text": "
### 通知\n 
来自**机器人**的通知
" } } 

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

 

 

 

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

原文:http://www.cnblogs.com/jerron/p/6501147.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!