Ali terminal using SMS service to send alarm data

1. Ali launched SMS service

First you have to have Ali cloud account

2. Get AK

In this era of money to move an inch, as long as you have money, you can get AK. As shown
Here Insert Picture Description
these two parameters behind the call interface will be used. At the moment, please Keguan stabilize, do not panic.

3. Configure Signature

SMS signature is a what?
Here Insert Picture Description
Seen this thing right. Listen to me, reminded flow is signed. There is no meal Maose so open.

But this thing ye set it?
Here Insert Picture Description

  1. Login SMS service console.
  2. In the left navigation bar, click the domestic SMS.
  3. In the upper right corner of the signature management tab, click Add signature.
  4. Fill out a signature, scenes, etc. applicable mandatory information.
  5. Fill in the business description. Business Description information is one of the reference signature auditing, information about signing applications, such as the scene described in detail, complete information to improve business briefing session reviewed the efficiency of signature.
  6. Click OK. Automatically submitted for review after you click OK.

4. lu Code

        //可自助调整超时时间
        System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
        System.setProperty("sun.net.client.defaultReadTimeout", "10000");
        //初始化acsClient,暂不支持region化
        IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
        DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
        IAcsClient acsClient = new DefaultAcsClient(profile);
        //组装请求对象-具体描述见控制台-文档部分内容
        SendSmsRequest request = new SendSmsRequest();
        //必填:待发送手机号
        request.setPhoneNumbers(telephone);
        //必填:短信签名-可在短信控制台中找到
        request.setSignName("大秦上天公司");    // TODO 修改成自己的
        //必填:短信模板-可在短信控制台中找到
        request.setTemplateCode("SMS_65535");    // TODO 修改成自己的
        //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
        request.setTemplateParam("我司领导真的是个大混子,大秦工业的通信研究生,给哥哥说他擅长前端,哎,屁都不会,一点不吹,上林苑四路的选手");
        //选填-上行短信扩展码(无特殊需求用户请忽略此字段)
        //request.setSmsUpExtendCode("90997");
        //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
        request.setOutId("yourOutId");
        //hint 此处可能会抛出异常,注意catch
        SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
        if(sendSmsResponse.getCode()!= null && sendSmsResponse.getCode().equals("OK")){
            log.info("短信发送成功!");
        }else {
            log.info("短信发送失败!");
        }

This is the official minor modifications to the case

Blow off steam

This function is added to the platform things, send an SMS notification to the terminal in response to the alarm management. SSM needs to be added to the project in an Eclipse development, wood Maven, only jar. Jar to import
Here Insert Picture Description
the problem came.

//初始化acsClient,暂不支持region化
        IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);

In this piece, under the circumstances I have described the project, the error. Hang it
needs Gson Caesar. . .

Another episode, our company to a customer when the gun went to the country prefix operators to demonstrate, to change

 //必填:短信签名-可在短信控制台中找到
        request.setSignName("大秦上林苑四路办事处");    // TODO 修改成自己的名号

I Pidianpidian changed. The results forced the ignorant, the terminal alarm, SMS too! SMS too! SMS too!
Later, after I step by step investigation, noticed the top of the comments, it is a signature.

Things to join SMS alert platform but it is still good.
Today show ends! The objective is still something of money to drop me.

Guess you like

Origin blog.csdn.net/m0_38008027/article/details/91571948