|
@@ -1,3 +1,4 @@
|
|
|
+using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
using Aliyun.Acs.Core;
|
|
|
using Aliyun.Acs.Core.Exceptions;
|
|
@@ -9,6 +10,12 @@ namespace GxPress.Common.Sms
|
|
|
{
|
|
|
public static class AliySms
|
|
|
{
|
|
|
+ /// <summary>
|
|
|
+ /// 登录验证码
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="phone"></param>
|
|
|
+ /// <param name="code"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public static bool SendSms(string phone, string code)
|
|
|
{
|
|
|
//发送验证码阿里云
|
|
@@ -41,5 +48,117 @@ namespace GxPress.Common.Sms
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 通知
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="phone"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static bool NoticeSendSms(List<string> phones)
|
|
|
+ {
|
|
|
+ //发送验证码阿里云
|
|
|
+ IClientProfile profile =
|
|
|
+ DefaultProfile.GetProfile("cn-hangzhou", "LTAI4GKu41MJT8HBxdGAUSWU", "huEFjWImOBDmzyJ8jdive83BXpQm1V");
|
|
|
+ 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", $"({Common.Tools.StringUtils.ObjectCollectionToString(phones)})");
|
|
|
+ request.AddQueryParameters("SignName", "同岑");
|
|
|
+ request.AddQueryParameters("TemplateCode", "SMS_191490083");
|
|
|
+ //request.AddQueryParameters("TemplateParam", "{\"code\":\"" + code + "\"}");
|
|
|
+ try
|
|
|
+ {
|
|
|
+ CommonResponse response = client.GetCommonResponse(request);
|
|
|
+ if (response.HttpStatus == 200)
|
|
|
+ {
|
|
|
+ //var codeByte = Encoding.UTF8.GetBytes(Utilities.JsonSerialize(code));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (ServerException e)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 工作流程状态短信
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="phone"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static bool FolwStatusSendSms(string phone)
|
|
|
+ {
|
|
|
+ //发送验证码阿里云
|
|
|
+ IClientProfile profile =
|
|
|
+ DefaultProfile.GetProfile("cn-hangzhou", "LTAI4GKu41MJT8HBxdGAUSWU", "huEFjWImOBDmzyJ8jdive83BXpQm1V");
|
|
|
+ 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", "SMS_191490081");
|
|
|
+ //request.AddQueryParameters("TemplateParam", "{\"code\":\"" + code + "\"}");
|
|
|
+ try
|
|
|
+ {
|
|
|
+ CommonResponse response = client.GetCommonResponse(request);
|
|
|
+ if (response.HttpStatus == 200)
|
|
|
+ {
|
|
|
+ //var codeByte = Encoding.UTF8.GetBytes(Utilities.JsonSerialize(code));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (ServerException e)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 工作流程审核短信
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="phone"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static bool FolwCheckSendSms(string phone)
|
|
|
+ {
|
|
|
+ //发送验证码阿里云
|
|
|
+ IClientProfile profile =
|
|
|
+ DefaultProfile.GetProfile("cn-hangzhou", "LTAI4GKu41MJT8HBxdGAUSWU", "huEFjWImOBDmzyJ8jdive83BXpQm1V");
|
|
|
+ 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", "SMS_191490079");
|
|
|
+ //request.AddQueryParameters("TemplateParam", "{\"code\":\"" + code + "\"}");
|
|
|
+ try
|
|
|
+ {
|
|
|
+ CommonResponse response = client.GetCommonResponse(request);
|
|
|
+ if (response.HttpStatus == 200)
|
|
|
+ {
|
|
|
+ //var codeByte = Encoding.UTF8.GetBytes(Utilities.JsonSerialize(code));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (ServerException e)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|