发短信:
登入阿里云官网:
申请短信模板
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 string accessKeyId = "这儿是你的accessKeyId"; 6 string accessKeySecret = "这儿是你的accessKeySecret"; 7 8 string phoneNumbers = "13806412311"; 9 string signName = "我是签名"; 10 string templateCode = "SMS_0..."; 11 string name = "我是name"; 12 string Class = "我是Class"; 13 string uniqueIdentification = Guid.NewGuid().ToString("N"); 14 15 IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", accessKeyId, accessKeySecret); 16 DefaultAcsClient client = new DefaultAcsClient(profile); 17 CommonRequest request = new CommonRequest(); 18 request.Method = MethodType.POST; 19 request.Domain = "dysmsapi.aliyuncs.com"; 20 request.Version = "2017-05-25"; 21 request.Action = "SendSms"; 22 request.AddQueryParameters("PhoneNumbers", phoneNumbers); 23 request.AddQueryParameters("SignName", signName); 24 request.AddQueryParameters("TemplateCode", templateCode); 25 request.AddQueryParameters("TemplateParam", "{'name':'" + name + "','class':'" + Class + "'}"); 26 request.AddQueryParameters("OutId", uniqueIdentification); 27 // request.Protocol = ProtocolType.HTTP; 28 try 29 { 30 CommonResponse response = client.GetCommonResponse(request); 31 Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content)); 32 Console.ReadLine(); 33 } 34 catch (ServerException e) 35 { 36 Console.WriteLine(e); 37 } 38 catch (ClientException e) 39 { 40 Console.WriteLine(e); 41 } 42 43 } 44 }
给申请的阿里云服务器开端口
阿里云官网:https://www.aliyun.com/
步骤:控制台--->(产品与服务)云服务器ECS--->安全组(配置规则)---进行手动添加端口即可