Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

unikueltd/sms-sender-spring-boot-starter

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sms Sender Spring Boot Starter

Spring Boot application integrates sms-sender, support various sms engines.

Quickstart

  • Import dependencies
    <dependency>
        <groupId>cn.unikue.springstarter</groupId>
        <artifactId>sms-sender-spring-boot-starter</artifactId>
        <version>LATEST</version>
    </dependency>

By default, this starter will auto take effect, you can turn it off by spring.sms-sender.enabled = false

  • Configure Spring Boot application.yml with prefix spring.sms-sender
spring:
    sms-sender:
        sender-type: 'tencent'
        aliyun:
            access-key-id: 'your-access-key'
            access-key-secret: 'your-secret-key'
            region: 'cn-beijing'
        tencent:
            secret-id: 'your-secret-id'
            secret-key: 'your-secret-key'
            region: 'ap-beijing'
            default-app-id: 'your-default-app-id'
            default-sign-name: 'your-default-sign-name'
  • Then, in your code, you can use SmsSenderComposer to send and query sms
@Service
public class DemoService {
    @Autowired
    private SmsSenderComposer senderComposer;

    public void demoMethod() {
        // Sends a plain sms
        SendPlainSmsParam sendParam = new SendPlainSmsParam();
        sendParam.setMobilePhones(Collections.singleton("+86-13800138000"));
        sendParam.setTemplateCode("1234567890");
        sendParam.setTemplateParams(Maps.of("verifyCode", "123456"));
        String receiptId = senderComposer.sendPlainSms(sendParam);

        // Queries the status of a sms
        QuerySmsStatusParam queryParam = new QuerySmsStatusParam();
        sendParam.setMobilePhone("+86-13800138000");
        sendParam.setReceiptId(receiptId);
        sendParam.setSentDate(LocalDate.now());
        List<QuerySmsStatusResult> queryResults = senderComposer.querySmsStatus(queryParam);

        // Gets the raw client for advanced usage
        senderComposer.getRawClient();
        senderComposer.getRawClientAs(expectType);
    }
}

Document

Requirement

  • jdk 17+

License

This project is under the Apache License 2.0

See the NOTICE.txt file for required notices and attributions.

Donation

You like this package? Then donate to us to support the development.

Copyright

Beijing Unikue Network Technology Ltd.

Website

About

Sms Sender for Spring Boot Starter

Resources

Stars

Watchers

Forks

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.