private static SendAliSmsReq GetSendAliSmsReq(NotifyTemplateMo template, NotifyReq msg) { var aliMsg = new SendAliSmsReq(); aliMsg.PhoneNums = msg.targets; aliMsg.body_paras = msg.body_paras; aliMsg.sign_name = template.sign_name; aliMsg.template_code = template.t_plat_code; return(aliMsg); }
public static SendAliSmsReq ToAliSmsReq(this SendSmsReq req) { var aliReq = new SendAliSmsReq { PhoneNums = req.PhoneNums, body_paras = req.body_paras, sign_name = req.sign_name, template_code = req.template_code }; return(aliReq); }
public async Task <SendAliSmsResp> Send(SendAliSmsReq sendReq) { var appConfigRes = await GetMeta(); if (!appConfigRes.IsSuccess()) { return(new SendAliSmsResp().WithResp(appConfigRes)); } var appConfig = appConfigRes.data; var dirs = new SortedDictionary <string, string>(StringComparer.Ordinal) { { "Action", "SendSms" }, { "Version", appConfig.Version }, { "RegionId", appConfig.RegionId }, { "PhoneNumbers", string.Join(",", sendReq.PhoneNums) }, { "SignName", sendReq.sign_name }, { "TemplateCode", sendReq.template_code } }; if (sendReq.body_paras != null && sendReq.body_paras.Count > 0) { var temparas = JsonConvert.SerializeObject(sendReq.body_paras); dirs.Add("TemplateParam", temparas); } FillApiPara(appConfig, dirs); var req = new OssHttpRequest { AddressUrl = string.Concat("http://dysmsapi.aliyuncs.com?", GeneratePostData(appConfig, dirs)), HttpMethod = HttpMethod.Get }; using (var resp = await req.RestSend()) { var content = await resp.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <SendAliSmsResp>(content)); } }