mirror of
https://gitee.com/dromara/sms4j.git
synced 2025-12-07 09:29:08 +08:00
commit
c8685f620b
1
pom.xml
1
pom.xml
@ -19,6 +19,7 @@
|
|||||||
<module>sms4j-autoimmit</module>
|
<module>sms4j-autoimmit</module>
|
||||||
<module>sms4j-spring-boot-starter</module>
|
<module>sms4j-spring-boot-starter</module>
|
||||||
<module>sms4j-solon-plugin</module>
|
<module>sms4j-solon-plugin</module>
|
||||||
|
<module>sms4j-spring-boot-example</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<!-- 开源协议 Apache 2.0 -->
|
<!-- 开源协议 Apache 2.0 -->
|
||||||
|
|||||||
40
sms4j-spring-boot-example/pom.xml
Normal file
40
sms4j-spring-boot-example/pom.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.dromara.sms4j</groupId>
|
||||||
|
<artifactId>sms4j</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>sms4j-spring-boot-example</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${spring.boot.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--单元测试-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.dromara.sms4j</groupId>
|
||||||
|
<artifactId>sms4j-spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package org.dromara.sms4j.example;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主类
|
||||||
|
*
|
||||||
|
* @author handy
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
public class Sms4jApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(Sms4jApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
29
sms4j-spring-boot-example/src/main/resources/application.yml
Normal file
29
sms4j-spring-boot-example/src/main/resources/application.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
sms:
|
||||||
|
alibaba:
|
||||||
|
#阿里云的accessKey
|
||||||
|
accessKeyId: 您的accessKey
|
||||||
|
#阿里云的accessKeySecret
|
||||||
|
accessKeySecret: 您的accessKeySecret
|
||||||
|
#短信签名
|
||||||
|
signature: 测试签名
|
||||||
|
#模板ID 用于发送固定模板短信使用
|
||||||
|
templateId: SMS_215125134
|
||||||
|
#模板变量 上述模板的变量
|
||||||
|
templateName: code
|
||||||
|
#请求地址 默认为dysmsapi.aliyuncs.com 如无特殊改变可以不用设置
|
||||||
|
requestUrl: dysmsapi.aliyuncs.com
|
||||||
|
huawei:
|
||||||
|
#华为短信appKey
|
||||||
|
appKey: 5N6fvXXXX920HaWhVXXXXXX7fYa
|
||||||
|
#华为短信appSecret
|
||||||
|
app-secret: Wujt7EYzZTBXXXXXXEhSP6XXXX
|
||||||
|
#短信签名
|
||||||
|
signature: 华为短信测试
|
||||||
|
#通道号
|
||||||
|
sender: 8823040504797
|
||||||
|
#模板ID 如果使用自定义模板发送方法可不设定
|
||||||
|
template-id: acXXXXXXXXc274b2a8263479b954c1ab5
|
||||||
|
#华为回调地址,如不需要可不设置或为空
|
||||||
|
statusCallBack:
|
||||||
|
#华为分配的app请求地址
|
||||||
|
url: https://XXXXX.cn-north-4.XXXXXXXX.com:443
|
||||||
@ -1,5 +1,7 @@
|
|||||||
package org.dromara.sms4j.test;
|
package org.dromara.sms4j.example;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.dromara.sms4j.api.entity.SmsResponse;
|
import org.dromara.sms4j.api.entity.SmsResponse;
|
||||||
import org.dromara.sms4j.comm.enumerate.SupplierType;
|
import org.dromara.sms4j.comm.enumerate.SupplierType;
|
||||||
import org.dromara.sms4j.core.config.SupplierFactory;
|
import org.dromara.sms4j.core.config.SupplierFactory;
|
||||||
@ -9,8 +11,8 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class Sms4jTest {
|
class Sms4jTest {
|
||||||
public static final String USER_AGENT = "uni-java-sdk" + "/0.0.4" ;
|
public static final String USER_AGENT = "uni-java-sdk" + "/0.0.4";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void uniSmsTest() {
|
public void uniSmsTest() {
|
||||||
@ -30,4 +32,15 @@ public class Sms4jTest {
|
|||||||
// Uni.getClient().request("sms.message.send",mes)
|
// Uni.getClient().request("sms.message.send",mes)
|
||||||
// UniClient.request()
|
// UniClient.request()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void alibabaSmsTest() {
|
||||||
|
String phone = "";
|
||||||
|
if (StrUtil.isBlank(phone)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SmsResponse smsResponse = SmsFactory.createSmsBlend(SupplierType.ALIBABA).sendMessage(phone, "123456");
|
||||||
|
Assert.isTrue("OK".equals(smsResponse.getCode()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user