void Send_SMS(string phoneNumber, string code)
{
if (string.IsNullOrEmpty(phoneNumber) || string.IsNullOrEmpty(code))
{
return;
}
Debug.Log(phoneNumber);
try
{
IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", "LTAI4G27BxEb5XmJirg6L6By", "LqBtT8YbcivNiRRSgbfoDguHOBszcx");
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", phoneNumber);
request.AddQueryParameters("SignName", "更换签名等参数");
request.AddQueryParameters("TemplateCode", "SMS_188642469");
request.AddQueryParameters("TemplateParam", "{'code':'" + code + "'}");
try
{
CommonResponse response = client.GetCommonResponse(request);
Debug.Log(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
}
catch (ServerException e)
{
Debug.Log("ServerException:" + e);
}
catch (ClientException e)
{
Debug.Log("ClientException:" + e);
}
}
catch (Exception e)
{
Debug.Log("Exception" + e);
}
}
Unity使用阿里云发送短信
最新推荐文章于 2022-07-19 11:03:46 发布