Alibaba Cloud SMS Development Documentation

Aliyun SMS Development Document
Official document: https://help.aliyun.com/document_detail/55284.html
1: Recharge 1 yuan (you need money to send SMS, if the account has no money, an error will be reported)
2: Create an Aliyun secret key (AccessKey )
3: Add signature
4: Add template
5: Download SDK
    Download address: https://help.aliyun.com/document_detail/55359.html?spm=a2c4g.11186623.2.8.UhJ7AT

6: You need to package the Jar package into the Maven repository.
    Package command:

mvn install:install-file -Dfile=F:/Sdk4J.jar -DgroupId=com.sdk4j -DartifactId=sdk4j -Dversion=1.0 -Dpackaging=jar


    Package the two jar packages in the \dysms_java\java\api_sdk directory into the Maven repository
    
7: Start Eclipse, import the Maven project dysms_java\java\api_demo\alicom-dysms-api, and import the above two jar packages into the project
8: Change the information in the Demo

     // TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)这里填写的是Access Key的信息,第二步中创建的Access Key
    static final String accessKeyId = "XXXXXX";
    static final String accessKeySecret = "XXXXXX";


    //必填:待发送手机号
        request.setPhoneNumbers("XXXXXX");
        //必填:短信签名-可在短信控制台中找到  这里填写的是“签名管理 --> 签名名称"
        request.setSignName("XXXXXX");            
        //必填:短信模板-可在短信控制台中找到    这里填写的是“模板管理 --> 模板CODE"
        request.setTemplateCode("XXXXXX");
        //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
        request.setTemplateParam("{\"code\":\"123\"}");

    //必填-手机号
        request.setPhoneNumber("XXXXXX");


9: Just run the main method

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325479500&siteId=291194637