Skip to content

阿里云短信服务

Yugang Zhou edited this page Jun 13, 2019 · 1 revision

Daming提供了对阿里云短信服务的实现,您可以通过配置将其打开

# application-{profile}.properties
daming.sms.provider=aliyun

使用如下配置注入access keysecret

daming.aliyun.accessKeyId={your key id}
daming.aliyun.accessKeySecret={your key secret}

或者直接注入经过定制的IAcsClient实例:

@Bean(name="acsClient")
public IAcsClient acsClient() {
    IClientProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
    DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", "Dysmsapi", "dysmsapi.aliyuncs.com");
    // other configurations
    return new DefaultAcsClient(profile);
}

最后通过配置注入短信签名和模板代码(在阿里云短信控制台可以找到这些信息)

daming.aliyun.sms.signature={your text} #encode it in unicode
daming.aliyun.sms.templateCode={your code}

Clone this wiki locally