阿里云短信服务的申请,请直接参考官方文档:短信发送API(SendSms)---JAVA ,本博客分享的是具体的后端代码实现哦。
首先是要引入需要的jar包:
<!-- 阿里云短信开始 -->
<!-- https://mvnrepository.com/artifact/com.github.suxingli/aliyuncs -->
<dependency>
<groupId>com.github.suxingli</groupId>
<artifactId>aliyuncs</artifactId>
<version>1.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-dysmsapi -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>1.1.0</version>
</dependency>
<!-- 阿里云短信结束 -->
下面是实现代码:
package util.mobile;
import java