Commit cd133de0 authored by wux's avatar wux

新增短信平台对接

parent 7381d240
package cn.iocoder.yudao.framework.http.sms;
import cn.iocoder.yudao.framework.http.core.Request;
import cn.iocoder.yudao.framework.http.core.Response;
import cn.iocoder.yudao.framework.http.core.client.HttpClient;
import cn.iocoder.yudao.framework.http.core.client.HttpClientFactory;
import java.util.HashMap;
import java.util.Map;
/**
* @author wuxian
* @since 2024-11-27
**/
public class BulksmsHttp {
private static final String REQ_URL = "https://portal.nigeriabulksms.com/api/";
public void sendReq(Map<String, Object> param, Map<String, String> header) {
HttpClient client = HttpClientFactory.get(Request.Util.OkHttp);
Request req = Request.create(REQ_URL, Request.Method.POST, param);
req.setParamFormat(Request.ParamFormat.FORM);
try {
Response res = client.execute(req, Request.Option.create(0, 0, header));
System.out.println("response code ---------------------------->" + res.getCode());
System.out.println("response content is --------------------》" + res.getBody());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private static Map<String, String> setHeader(String accept, String contentType) {
Map<String, String> header = new HashMap<>();
//header.put("Accept","application/json,text/plain,*/*");
//header.put("Content-Type", "application/json");
header.put("Accept", accept);
header.put("Content-Type", contentType);
return header;
}
public static void main(String[] args){
BulksmsHttp test = new BulksmsHttp();
Map<String,String> header = setHeader("text/html,application/xhtml+xml,application/xml","application/json");
String mobiles = "18102810628";
String sender = "ECLogistics";
String message = "Good day This is E&C logistics(ship from China to Nigeria),It has been a while since we last worked together,and we would like to reestablish our partnership. Our main service:GROUPAGE/FULL CONTAINER/AIR CARGO/COMPRESSING/CONSOLITAION .We value your business and would appreciate the opportunity to serve you once again.Have a Nice day! My WA :+861 592 035 652 7";
Map<String, Object> param = new HashMap<>();
param.put("username","ecit@ewchina.net");
param.put("password","0z@@vtj1h");
test.sendReq(param,header);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment