use of com.tencentcloudapi.sms.v20190711.models.SendSmsRequest in project knife-starter by 1120023921.
the class KnifeSmsAliServiceImpl method sendSms.
@Override
public AliSmsResult sendSms(AliSms aliSms) {
try {
final Client client = knifeSmsAliSenderContext.getClient();
final SendSmsRequest sendSmsRequest = new SendSmsRequest();
BeanUtils.copyProperties(aliSms, sendSmsRequest);
final SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest);
return AliSmsResult.builder().msgId(aliSms.getMsgId()).code(sendSmsResponse.getBody().getCode()).errMsg(sendSmsResponse.getBody().getMessage()).build();
} catch (Exception e) {
return AliSmsResult.builder().msgId(aliSms.getMsgId()).code("-1").errMsg(e.getMessage()).build();
}
}
use of com.tencentcloudapi.sms.v20190711.models.SendSmsRequest in project rhythm by csfwff.
the class VerifycodeMgmtService method sendMsg.
public boolean sendMsg(String[] phoneNumber, String[] templateParam) {
if (Latkes.getRuntimeMode().equals(Latkes.RuntimeMode.DEVELOPMENT)) {
LOGGER.log(Level.INFO, "开发模式不真正发送短信,发送的手机号为:{},当前短信验证码为:{}", phoneNumber, templateParam);
return true;
} else {
Credential cred = new Credential(Symphonys.TEN_SMS_SECRET_ID, Symphonys.TEN_SMS_SECRET_KEY);
SmsClient client = new SmsClient(cred, Symphonys.TEN_SMS_DIYU);
SendSmsRequest req = new SendSmsRequest();
req.setSmsSdkAppId(Symphonys.TEN_SMS_SDK_APPID);
req.setSignName(Symphonys.TEN_SMS_SIGN_NAME);
req.setTemplateId(Symphonys.TEN_SMS_TEMPLATE_ID);
req.setPhoneNumberSet(phoneNumber);
req.setTemplateParamSet(templateParam);
SendSmsResponse res = null;
try {
res = client.SendSms(req);
} catch (TencentCloudSDKException e) {
LOGGER.log(Level.ERROR, "Unable send SMS [phoneNumber={}, templateParam={}]", phoneNumber, templateParam);
return false;
}
assert res != null;
LOGGER.log(Level.INFO, SendSmsResponse.toJsonString(res));
return true;
}
}
use of com.tencentcloudapi.sms.v20190711.models.SendSmsRequest in project austin by ZhongFuCheng3y.
the class TencentSmsScript method assembleReq.
/**
* 组装发送短信参数
*/
private SendSmsRequest assembleReq(SmsParam smsParam, TencentSmsParam account) {
SendSmsRequest req = new SendSmsRequest();
String[] phoneNumberSet1 = smsParam.getPhones().toArray(new String[smsParam.getPhones().size() - 1]);
req.setPhoneNumberSet(phoneNumberSet1);
req.setSmsSdkAppId(account.getSmsSdkAppId());
req.setSignName(account.getSignName());
req.setTemplateId(account.getTemplateId());
String[] templateParamSet1 = { smsParam.getContent() };
req.setTemplateParamSet(templateParamSet1);
req.setSessionContext(IdUtil.fastSimpleUUID());
return req;
}
use of com.tencentcloudapi.sms.v20190711.models.SendSmsRequest 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.SendSmsRequest 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;
}
Aggregations