day02/bwie-common/src/main/java/com/bwie/common/utils/MsgUtil.java

42 lines
1.2 KiB
Java

package com.bwie.common.utils;
import org.apache.http.HttpResponse;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* @author
* @version 1.0.0
* @ClassName MsgUtil.java
* @Description TODO
* @createTime 2022年05月26日 15:49:00
*/
@Component
public class MsgUtil {
public void sendMsg(String phone,String code){
String host = "http://dingxin.market.alicloudapi.com";
String path = "/dx/sendSms";
String method = "POST";
String appcode = "dcb3dabebd3843a7a138901659ed112e";
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + appcode);
Map<String, String> querys = new HashMap<String, String>();
querys.put("mobile", phone);
querys.put("param", "code:"+code);
querys.put("tpl_id", "TP1711063");
Map<String, String> bodys = new HashMap<String, String>();
try {
HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
System.out.println(response.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}