|
@@ -20,17 +20,45 @@ public class CSHuaGuServiceImpl implements CSHuaGuService {
|
|
|
|
|
|
|
|
private final CSHuaGuConf csHuaGuConf;
|
|
private final CSHuaGuConf csHuaGuConf;
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean sendSmsValidCode(String mobile, String message) {
|
|
|
|
|
+ log.info("开始发送短信--->" + mobile + ",内容--->" + message);
|
|
|
|
|
+ JSONObject body = new JSONObject();
|
|
|
|
|
+ body.put("apikey", csHuaGuConf.getSmsApiKey());
|
|
|
|
|
+ body.put("phone", mobile);
|
|
|
|
|
+ body.put("context", message);
|
|
|
|
|
+ body.put("secret", csHuaGuConf.getSmsApisecret());
|
|
|
|
|
+ String result = "";
|
|
|
|
|
+ try {
|
|
|
|
|
+ result = HttpUtil.createPost(csHuaGuConf.getSmsApiurl())
|
|
|
|
|
+ .body(body.toJSONString())
|
|
|
|
|
+ .contentType("application/json")
|
|
|
|
|
+ .execute()
|
|
|
|
|
+ .body();
|
|
|
|
|
+ JSONObject resultJson = JSON.parseObject(result);
|
|
|
|
|
+ if (resultJson.getInteger("code") == 200) {
|
|
|
|
|
+ log.info("发送短信成功--->" + result);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("发送短信失败--->" + result);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("发送短信异常--->" + result);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public boolean sendValidCode(String mobile, String message) {
|
|
public boolean sendValidCode(String mobile, String message) {
|
|
|
log.info("开始发送短信--->" + mobile + ",内容--->" + message);
|
|
log.info("开始发送短信--->" + mobile + ",内容--->" + message);
|
|
|
JSONObject body = new JSONObject();
|
|
JSONObject body = new JSONObject();
|
|
|
body.put("phone", mobile);
|
|
body.put("phone", mobile);
|
|
|
body.put("context", message);
|
|
body.put("context", message);
|
|
|
- body.put("apikey", csHuaGuConf.getApikey());
|
|
|
|
|
- body.put("secret", csHuaGuConf.getApisecret());
|
|
|
|
|
|
|
+ body.put("apikey", csHuaGuConf.getApiKey());
|
|
|
|
|
+ body.put("secret", csHuaGuConf.getApiSecret());
|
|
|
String result = "";
|
|
String result = "";
|
|
|
try {
|
|
try {
|
|
|
- result = HttpUtil.createPost(csHuaGuConf.getApiurl())
|
|
|
|
|
|
|
+ result = HttpUtil.createPost(csHuaGuConf.getApiUrl())
|
|
|
.body(body.toJSONString())
|
|
.body(body.toJSONString())
|
|
|
.contentType("application/json")
|
|
.contentType("application/json")
|
|
|
.execute()
|
|
.execute()
|