use of com.tencentcloudapi.sms.v20190711.models.SendSmsResponse in project austin by ZhongFuCheng3y.
the class TencentSmsScript method send.
@Override
public List<SmsRecord> send(SmsParam smsParam) throws Exception {
TencentSmsParam tencentSmsParam = accountUtils.getAccount(smsParam.getSendAccount(), SMS_ACCOUNT_KEY, PREFIX, TencentSmsParam.builder().build());
SmsClient client = init(tencentSmsParam);
SendSmsRequest request = assembleReq(smsParam, tencentSmsParam);
SendSmsResponse response = client.SendSms(request);
return assembleSmsRecord(smsParam, response, tencentSmsParam);
}
use of com.tencentcloudapi.sms.v20190711.models.SendSmsResponse in project eladmin by lWoHvYe.
the class DySMSUtil method sendSms.
/**
* 发送短信
*
* @param phoneNumbers
* @param signName
* @param templateCode
* @param templateParam
* @return java.lang.String
* @date 2021/11/7 12:53 下午
*/
@SneakyThrows
public static String sendSms(String phoneNumbers, String signName, String templateCode, String templateParam) {
Client client = DySMSUtil.createClient();
// 1.发送短信
SendSmsRequest sendReq = new SendSmsRequest().setPhoneNumbers(phoneNumbers).setSignName(signName).setTemplateCode(templateCode).setTemplateParam(templateParam);
SendSmsResponse sendResp = client.sendSms(sendReq);
String code = sendResp.body.code;
if (!StrUtil.equals(code, "OK")) {
log.error("错误信息: {} ", sendResp.body.message);
return null;
}
return sendResp.body.bizId;
}
use of com.tencentcloudapi.sms.v20190711.models.SendSmsResponse in project heifer by galaxy-sea.
the class AliyunSmsServer method sendCaptcha.
@Override
public void sendCaptcha(String phoneNumbers, String captcha) {
SendSmsRequest sendSmsRequest = new SendSmsRequest().setPhoneNumbers(phoneNumbers).setSignName(this.aliyunSmsProperties.getSignName()).setTemplateCode(TemplateCode.SMS_185520034.toString()).setTemplateParam("{\"code\":\"" + captcha + "\"}");
SendSmsResponse sendSmsResponse;
try {
sendSmsResponse = this.client.sendSms(sendSmsRequest);
} catch (Exception e) {
throw new ResultException(ResultStatusEnum.SMS_NETWORK_EXCEPTION);
}
SendSmsResponseBody body = sendSmsResponse.getBody();
if (!OK.equals(body.getCode())) {
throw new ResultException(ResultStatusEnum.SMS_SEND_FAIL, body.getMessage());
}
}
use of com.tencentcloudapi.sms.v20190711.models.SendSmsResponse in project RuoYi-Cloud-Plus by JavaLionLi.
the class TencentSmsTemplate method send.
public SmsResult send(String phones, String templateId, Map<String, String> param) {
if (StringUtils.isBlank(phones)) {
throw new SmsException("手机号不能为空");
}
if (StringUtils.isBlank(templateId)) {
throw new SmsException("模板ID不能为空");
}
SendSmsRequest req = new SendSmsRequest();
Set<String> set = Arrays.stream(phones.split(",")).map(p -> "+86" + p).collect(Collectors.toSet());
req.setPhoneNumberSet(ArrayUtil.toArray(set, String.class));
if (CollUtil.isNotEmpty(param)) {
req.setTemplateParamSet(ArrayUtil.toArray(param.values(), String.class));
}
req.setTemplateID(templateId);
req.setSign(properties.getSignName());
req.setSmsSdkAppid(properties.getSdkAppId());
try {
SendSmsResponse resp = client.SendSms(req);
SmsResult.SmsResultBuilder builder = SmsResult.builder().isSuccess(true).message("send success").response(resp);
for (SendStatus sendStatus : resp.getSendStatusSet()) {
if (!"Ok".equals(sendStatus.getCode())) {
builder.isSuccess(false).message(sendStatus.getMessage());
break;
}
}
return builder.build();
} catch (Exception e) {
throw new SmsException(e.getMessage());
}
}
Aggregations