|
|
@@ -1,19 +1,43 @@
|
|
|
-//package com.nb.app.assistant.sms;
|
|
|
-//
|
|
|
-//import org.springframework.context.annotation.Configuration;
|
|
|
-//
|
|
|
-///**
|
|
|
-// * @author lifang
|
|
|
-// * @version 1.0.0
|
|
|
-// * @ClassName AliSmsClientConfig.java
|
|
|
-// * @Description TODO
|
|
|
-// * @createTime 2022年10月12日 10:52:00
|
|
|
-// */
|
|
|
-//@Configuration
|
|
|
-//public class AliSmsClientConfig {
|
|
|
-// public static IAcsClient createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
|
|
-// DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "<your-access-key-id>", "<your-access-key-secret>");
|
|
|
-// IAcsClient client = new DefaultAcsClient(profile);
|
|
|
-// return client;
|
|
|
-// }
|
|
|
-//}
|
|
|
+package com.nb.app.assistant.sms;
|
|
|
+
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import com.aliyun.dysmsapi20170525.*;
|
|
|
+import com.aliyun.teaopenapi.models.*;
|
|
|
+/**
|
|
|
+ * @author lifang
|
|
|
+ * @version 1.0.0
|
|
|
+ * @ClassName AliSmsClientConfig.java
|
|
|
+ * @Description TODO
|
|
|
+ * @createTime 2022年10月12日 10:52:00
|
|
|
+ */
|
|
|
+@Configuration
|
|
|
+public class AliSmsClientConfig {
|
|
|
+ @Bean
|
|
|
+ public Client creatClient() throws Exception {
|
|
|
+ com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
|
|
+ // 您的 AccessKey ID
|
|
|
+ .setAccessKeyId("LTAI4G7FA9ytMc76oNkJ45YJ")
|
|
|
+ // 您的 AccessKey Secret
|
|
|
+ .setAccessKeySecret("R7hOvMfiHb0PYroDqUDXAYgB9htQss");
|
|
|
+ config.endpoint = "dysmsapi.aliyuncs.com";
|
|
|
+ return new Client(config);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 使用AK&SK初始化账号Client
|
|
|
+ * @param accessKeyId
|
|
|
+ * @param accessKeySecret
|
|
|
+ * @return Client
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
|
|
+ com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
|
|
+ // 您的 AccessKey ID
|
|
|
+ .setAccessKeyId(accessKeyId)
|
|
|
+ // 您的 AccessKey Secret
|
|
|
+ .setAccessKeySecret(accessKeySecret);
|
|
|
+ // 访问的域名
|
|
|
+ config.endpoint = "dysmsapi.aliyuncs.com";
|
|
|
+ return new com.aliyun.dysmsapi20170525.Client(config);
|
|
|
+ }
|
|
|
+}
|