一、企业微信入参
企业微信配置 机器人助手 : https://work.weixin.qq.com/api/doc/90000/90136/91770
/// <summary> /// 企业微信机器人入参 /// </summary> public class WebHookInput { /// <summary> /// 消息类型,此时固定为text /// </summary> public string msgtype { get { return "text"; } } /// <summary> /// 文本内容 /// </summary> public WebHookTextInput text { get; set; } } public class WebHookTextInput { /// <summary> /// 文本内容,最长不超过2048个字节,必须是utf8编码 /// </summary> public string content { get; set; } }
二、post请求公共方法
public static Toutput PostRequest<Toutput, Tinput>(string url, Tinput input) { Toutput output = default; if (string.IsNullOrEmpty(url)) return output; try { string inputParam = JsonConvert.SerializeObject(input); string result = GetPostUrl(url, inputParam); if (!string.IsNullOrEmpty(result)) { output = JsonConvert.DeserializeObject<Toutput>(result); } } catch (Exception ex) { } return output; } //post private static string GetPostUrl(string url, string postData, Dictionary<string, string> heardsDic = null) { string result = string.Empty;