接口文件

This commit is contained in:
“wanyongkang”
2024-04-10 13:55:27 +08:00
parent fff6bee06a
commit ed3b2c653e
3190 changed files with 268248 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Http;
using Aliyun.Acs.Core.Profile;
using Hncore.Infrastructure.Serializer;
using System;
using System.Collections.Generic;
namespace Hncore.Infrastructure.SMS
{
/// <summary>
/// 发送短信
/// </summary>
public class AliSmsService
{
public static bool Send(string TemplateCode,object TemplateParam, string SignName="", params string[] PhoneNumbers)
{
IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", "LTAI4FmSkDSwFuXeLxsDB3jB", "r8FfRmoeWcCJyZSqqkQP2G3dKPPl2N");
DefaultAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.Method = MethodType.POST;
request.Domain = "dysmsapi.aliyuncs.com";
request.Version = "2017-05-25";
request.Action = "SendSms";
// request.Protocol = ProtocolType.HTTP;
request.AddQueryParameters("PhoneNumbers", string.Join(",", PhoneNumbers));
request.AddQueryParameters("SignName", SignName);
request.AddQueryParameters("TemplateCode", TemplateCode);
request.AddQueryParameters("TemplateParam", TemplateParam.ToJson());
try
{
CommonResponse response = client.GetCommonResponse(request);
Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
return true;
}
catch (ServerException e)
{
Console.WriteLine(e);
}
catch (ClientException e)
{
Console.WriteLine(e);
}
return false;
}
}
}