zoukankan      html  css  js  c++  java
  • 钉钉微应用发送消息

    微应用就是网站,钉钉自带的E应用难用,而且前端UI都不是很好,所以倾向使用网站来开发

    string UrlUserID = "https://oapi.dingtalk.com/message/send?access_token=" + token;    //获取自己的Token
    
    
    
            string PostData = "{ "touser":"",  ";      //职员代码,不知道是什么 去通讯录上查,多个请用“|”区分
            PostData += "     "toparty":"", ";        //部门代码,职员代码和部门代码不能全部为空
            PostData += "          "agentid":"",   ";    //应用代码
            PostData += "         "msgtype":"text",  ";    //消息类型
            PostData += "         "text":{  ";
            PostData += "             "content":"37889"  ";    //消息内容
            PostData += "       }}";

    Response.Write(PostDataGetHtml(UrlUserID, PostData));
      public string PostDataGetHtml(string uri, string postData)
        {
            try
            {
                byte[] data = Encoding.UTF8.GetBytes(postData);
    
                Uri uRI = new Uri(uri);
                HttpWebRequest req = WebRequest.Create(uRI) as HttpWebRequest;
                req.Method = "POST";
                req.KeepAlive = true;
                req.ContentType = "application/json";
                req.ContentLength = data.Length;
                req.AllowAutoRedirect = true;
    
                Stream outStream = req.GetRequestStream();
                outStream.Write(data, 0, data.Length);
                outStream.Close();
    
                HttpWebResponse res = req.GetResponse() as HttpWebResponse;
                Stream inStream = res.GetResponseStream();
                StreamReader sr = new StreamReader(inStream, Encoding.UTF8);
                string htmlResult = sr.ReadToEnd();
    
                return htmlResult;
            }
            catch (Exception ex)
            {
                return "网络错误:" + ex.Message.ToString();
            }
        }

    钉钉视频教程

  • 相关阅读:
    垂直渐变的Button
    winform下重画ListBox
    分享一个 C# Winfrom 下的 OutlookBar 控件的使用
    颜色下拉菜单(combox)
    Robot Framework 使用技巧 快捷键
    Batch 拷贝远程机器文件到本机指定目录下
    JMeter常用函数 使用图解
    SoapUI报ClientProtocolException错误
    Setup Script in SoapUI
    邮件自动回复
  • 原文地址:https://www.cnblogs.com/erph/p/10232251.html
Copyright © 2011-2022 走看看