public static AliyunCommonResponse SendSms(string templateCode, string phone, string jsonParams) { ApplicationLog.Info($"start SendSms:{templateCode},json:{jsonParams}"); IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", "LTAIs7TC8gUyoffn", "A6OKeTXS9Dwk64Zm6xEgMrWzFBO20S"); DefaultAcsClient client = new DefaultAcsClient(profile); CommonRequest request = new CommonRequest { Method = MethodType.POST, Domain = "dysmsapi.aliyuncs.com", Version = "2017-05-25", Action = "SendSms" }; request.AddQueryParameters("PhoneNumbers", phone); request.AddQueryParameters("SignName", "建设公司综合管理部档案室"); request.AddQueryParameters("TemplateCode", templateCode); request.AddQueryParameters("TemplateParam", jsonParams); try { CommonResponse response = client.GetCommonResponse(request); ApplicationLog.Info($"end SendSms:{templateCode},json:{jsonParams}; response:{response.Data}"); return(response.Data.Deserialize <AliyunCommonResponse>()); } //catch (ServerException e) //{ // Console.WriteLine(e); //} //catch (ClientException e) //{ // Console.WriteLine(e); //} catch (Exception ex) { ApplicationLog.Error("end SendSms Exception", ex); } return(null); }
/// <summary> /// 序列化 /// </summary> /// <param name="obj"></param> /// <returns></returns> public static void SerializeToLog(this object obj, string title) { ApplicationLog.Info($"{title} :{(obj == null ? "is empty." : Serialize(obj))}"); }