使用钉钉提供的SDK(https://developers.dingtalk.com/document/resourcedownload?pnamespace=app)
IDingTalkClient client = new DefaultDingTalkClient($"https://oapi.dingtalk.com/robot/send?access_token=8f0430eff5a4b900***");
OapiRobotSendRequest request = new OapiRobotSendRequest();
//request.Msgtype = "text";
//OapiRobotSendRequest.TextDomain text = new OapiRobotSendRequest.TextDomain();
//text.Content = "111 测试文本消息";//111 是关键词和设置的一致即可
//request.Text_ = text;
OapiRobotSendRequest.AtDomain at = new OapiRobotSendRequest.AtDomain();
at.AtMobiles = new List<string> { "188********" };
// isAtAll类型如果不为Boolean,请升级至最新SDK
at.IsAtAll = false;
request.At_ = at;
request.Msgtype = "link";
OapiRobotSendRequest.LinkDomain link = new OapiRobotSendRequest.LinkDomain();
link.MessageUrl = "https://www.dingtalk.com/";
link.PicUrl = "";
link.Title = "时代的火车向前开";
link.Text = "111 这个即将发布的新版本,创始人xx称它为红树林。而在此之前,每当面临重大升级,产品经理们都会取一个应景的代号,这一次,为什么是红树林";//111 是关键词和设置的一致即可
request.Link_ = link;
//request.Msgtype = "markdown";
//OapiRobotSendRequest.MarkdownDomain markdown = new OapiRobotSendRequest.MarkdownDomain();
//markdown.Title = "杭州天气";
//markdown.Text = "111 #### 杭州天气
" +
// "> 9度,西北风1级,空气良89,相对温度73%
" +
// "> ![screenshot](https://gw.alicdn.com/tfs/TB1ut3xxbsrBKNjSZFpXXcXhFXa-846-786.png)
" +
// "> ###### 10点20分发布 [天气](http://www.thinkpage.cn/)
";//111 是关键词和设置的一致即可
//request.Markdown_ = markdown;
OapiRobotSendResponse response = client.Execute(request);