P15GEN2\59518
2024-05-29 d4210c7c4b04abde20037ea8aa0f54ef8a2649aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package foundation.send.sms;
 
import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.teautil.models.RuntimeOptions;
 
 
public class AliyunSMSProvider2 { 
    
    private static AliyunSMSProvider2 instance;
    
    
    public static synchronized AliyunSMSProvider2 getInstance() {
        if (instance == null) {
            instance = new AliyunSMSProvider2();
        }
 
        return instance;
    }
 
    public static void main(String[] args) throws Exception {
        Config config = new Config();
        config.setAccessKeyId("LTAI4G92tbAbpbN9eLbyFDdx");
        config.setAccessKeySecret("bbGYrr1oYQQf3MDA3yNOkZswxn8UBi");
//                                                     .setType("sts");
        config.endpoint = "dysmsapi.aliyuncs.com";
 
        Client client = new Client(config);
        
        SendSmsRequest sendSmsRequest = new SendSmsRequest()
                                        .setSignName("阿里云短信测试")
                                        .setTemplateCode("SMS_284995800")
                                        .setPhoneNumbers("18350350522")
                                        .setTemplateParam("{\"code\":\"03620\"}");
        
        RuntimeOptions runtime = new RuntimeOptions();
        SendSmsResponse resp = client.sendSmsWithOptions(sendSmsRequest, runtime);
        
        System.out.println(resp.getBody().toString());
    }
 
}