其他分享
首页 > 其他分享> > 2021-01-07

2021-01-07

作者:互联网

短信发送,智能门锁待知

package com.bnb;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import org.junit.Test;

import java.rmi.ServerException;
import java.util.HashMap;

public class AddSmsSign {
    public static void main(String[] args) {
        for(int i=0;i<5;i++){
        DefaultProfile profile = DefaultProfile.getProfile("****", "******", "*******");
        IAcsClient client = new DefaultAcsClient(profile);
        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.POST);
        request.setSysDomain("dysmsapi.aliyuncs.com");
        request.setSysVersion("2017-05-25");
        request.setSysAction("SendSms");
        request.putQueryParameter("PhoneNumbers", "手机号");
        request.putQueryParameter("SignName", "******");
        request.putQueryParameter("TemplateCode", "*****");
        HashMap<String, Object> map = new HashMap<>();
        map.put("content",1233);
        request.putQueryParameter("TemplateParam",JSONObject.toJSONString(map));
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }}
}


        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>aliyun-java-sdk-core</artifactId>
            <version>4.5.3</version>
        </dependency>













标签:aliyuncs,01,07,request,putQueryParameter,2021,import,com,HashMap
来源: https://blog.csdn.net/djdjbfbd/article/details/112341254