com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse Java Examples

The following examples show how to use com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SmsUtil.java    From codeway_service with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 查询发送详情
 * @param mobile
 * @param bizId
 * @return QuerySendDetailsResponse
 */
public QuerySendDetailsResponse querySendDetails(String mobile, String bizId) throws ClientException {

	//可自助调整超时时间
	System.setProperty("sun.net.client.defaultConnectTimeout","10000");
	System.setProperty("sun.net.client.defaultReadTimeout", "10000");
	//初始化acsClient,暂不支持region化
	IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou",accessKeyId, accessKeySecret);
	DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product,domain);
	IAcsClient acsClient = new DefaultAcsClient(profile);
	//组装请求对象
	QuerySendDetailsRequest request = new QuerySendDetailsRequest();
	//必填‐号码
	request.setPhoneNumber(mobile);
	//可选‐流水号
	request.setBizId(bizId);
	//必填‐发送日期 支持30天内记录查询,格式yyyyMMdd
	SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd");
	request.setSendDate(ft.format(new Date()));
	//必填‐页大小
	request.setPageSize(10L);
	//必填‐当前页码从1开始计数
	request.setCurrentPage(1L);
	//hint 此处可能会抛出异常,注意catch
	QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request);
	return querySendDetailsResponse;
}
 
Example #2
Source File: SmsUtil.java    From mogu_blog_v2 with Apache License 2.0 5 votes vote down vote up
public QuerySendDetailsResponse querySendDetails(String mobile, String bizId) throws ClientException {

        //可自助调整超时时间
        System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
        System.setProperty("sun.net.client.defaultReadTimeout", "10000");

        //初始化acsClient,暂不支持region化
        IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
        DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
        IAcsClient acsClient = new DefaultAcsClient(profile);

        //组装请求对象
        QuerySendDetailsRequest request = new QuerySendDetailsRequest();
        //必填-号码
        request.setPhoneNumber(mobile);
        //可选-流水号
        request.setBizId(bizId);
        //必填-发送日期 支持30天内记录查询,格式yyyyMMdd
        SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd");
        request.setSendDate(ft.format(new Date()));
        //必填-页大小
        request.setPageSize(10L);
        //必填-当前页码从1开始计数
        request.setCurrentPage(1L);

        //hint 此处可能会抛出异常,注意catch
        QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request);

        return querySendDetailsResponse;
    }
 
Example #3
Source File: AliSmsUtil.java    From charging_pile_cloud with MIT License 5 votes vote down vote up
/**
 * 查询短信详情类
 *
 * @param bizId
 * @return
 * @throws ClientException
 */
public static QuerySendDetailsResponse querySendDetails(String bizId) throws ClientException {

    //可自助调整超时时间
    System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
    System.setProperty("sun.net.client.defaultReadTimeout", "10000");

    //初始化acsClient,暂不支持region化
    IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
    DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
    IAcsClient acsClient = new DefaultAcsClient(profile);

    //组装请求对象
    QuerySendDetailsRequest request = new QuerySendDetailsRequest();
    //必填-号码
    request.setPhoneNumber("13015582371");
    //可选-流水号
    request.setBizId(bizId);
    //必填-发送日期 支持30天内记录查询,格式yyyyMMdd
    SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd");
    request.setSendDate(ft.format(new Date()));
    //必填-页大小
    request.setPageSize(10L);
    //必填-当前页码从1开始计数
    request.setCurrentPage(1L);

    //hint 此处可能会抛出异常,注意catch
    QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request);

    return querySendDetailsResponse;
}
 
Example #4
Source File: SmsUtil.java    From codeway_service with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 查询发送详情
 * @param mobile
 * @param bizId
 * @return QuerySendDetailsResponse
 */
public QuerySendDetailsResponse querySendDetails(String mobile, String bizId) throws ClientException {

	//可自助调整超时时间
	System.setProperty("sun.net.client.defaultConnectTimeout","10000");
	System.setProperty("sun.net.client.defaultReadTimeout", "10000");
	//初始化acsClient,暂不支持region化
	IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou",accessKeyId, accessKeySecret);
	DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product,domain);
	IAcsClient acsClient = new DefaultAcsClient(profile);
	//组装请求对象
	QuerySendDetailsRequest request = new QuerySendDetailsRequest();
	//必填‐号码
	request.setPhoneNumber(mobile);
	//可选‐流水号
	request.setBizId(bizId);
	//必填‐发送日期 支持30天内记录查询,格式yyyyMMdd
	SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd");
	request.setSendDate(ft.format(new Date()));
	//必填‐页大小
	request.setPageSize(10L);
	//必填‐当前页码从1开始计数
	request.setCurrentPage(1L);
	//hint 此处可能会抛出异常,注意catch
	QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request);
	return querySendDetailsResponse;
}
 
Example #5
Source File: SmsapiService.java    From FlyCms with MIT License 5 votes vote down vote up
public static QuerySendDetailsResponse querySendDetails(String PhoneNumber,String bizId,String accessKeyId,String accessKeySecret) throws ClientException {

        //可自助调整超时时间
        System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
        System.setProperty("sun.net.client.defaultReadTimeout", "10000");

        //初始化acsClient,暂不支持region化
        IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
        DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
        IAcsClient acsClient = new DefaultAcsClient(profile);

        //组装请求对象
        QuerySendDetailsRequest request = new QuerySendDetailsRequest();
        //必填-号码
        request.setPhoneNumber(PhoneNumber);
        //可选-流水号
        request.setBizId(bizId);
        //必填-发送日期 支持30天内记录查询,格式yyyyMMdd
        SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd");
        request.setSendDate(ft.format(new Date()));
        //必填-页大小
        request.setPageSize(10L);
        //必填-当前页码从1开始计数
        request.setCurrentPage(1L);

        //hint 此处可能会抛出异常,注意catch
        QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request);

        return querySendDetailsResponse;
    }
 
Example #6
Source File: SmsapiService.java    From FlyCms with MIT License 4 votes vote down vote up
/**
 * 手机注册验证码发送并保存
 * 
 * @param PhoneNumber
 *        要发送的手机号码
 * @param code
 *        指定发送的验证码
  * @param type
  *        1手机注册验证码,2安全手机设置验证码,3密码重置验证码
 * @return
 * @throws ClientException
 */
 @Transactional
public boolean mobileRegisterCode(String PhoneNumber,String code,int type) throws ClientException, InterruptedException{
     Smsapi api=smsapiDao.findSmsapiByid(1);
     String template=null;
     if(type==1){
         template=api.getRegCode();
     }else if(type==2){
         template=api.getSafeCode();
     }else if(type==3){
         template=api.getResetCode();
     }else{
         template=api.getRegCode();
     }
    SendSmsResponse response = sendSms(PhoneNumber,code,api.getAccessKeyId(), api.getAccessKeySecret(),api.getSignName(),template);
    Thread.sleep(3000L);
    //查明细
    if(response.getCode() != null && response.getCode().equals("OK")) {
        QuerySendDetailsResponse querySendDetailsResponse = querySendDetails(PhoneNumber,response.getBizId(),api.getAccessKeyId(), api.getAccessKeySecret());
        int i = 0;
        System.out.println("短信明细查询接口返回数据----------------");
        //查询发送状态
        for(QuerySendDetailsResponse.SmsSendDetailDTO smsSendDetailDTO : querySendDetailsResponse.getSmsSendDetailDTOs())
        {
            System.out.println("PhoneNum=" + smsSendDetailDTO.getPhoneNum());
            //发送成功状态为1则发送成功
            System.out.println("SendStatus=" + smsSendDetailDTO.getSendStatus());
            if(smsSendDetailDTO.getSendStatus()==1) {
                UserActivation activation=new UserActivation();
                SnowFlake snowFlake = new SnowFlake(2, 3);
                activation.setId(snowFlake.nextId());
                activation.setUserName(PhoneNumber);
                activation.setCode(code);
                activation.setCodeType(type);
                activation.setReferStatus(0);
                activation.setReferTime(new Date());
                userDao.addUserActivation(activation);
                return true;
            }
        }
    }
	return false;
}
 
Example #7
Source File: AliSMSServiceImpl.java    From sms with MIT License 4 votes vote down vote up
@Override
public QuerySendResult querySendStatus(App app, Message message) {
	try {
		QuerySendDetailsRequest request = new QuerySendDetailsRequest();
		// 必填-号码
		request.setPhoneNumber(message.getMobile());
		// 可选-调用发送短信接口时返回的BizId
		request.setBizId(message.getBizId());
		// 必填-短信发送的日期 支持30天内记录查询(可查其中一天的发送数据),格式yyyyMMdd
		request.setSendDate(new SimpleDateFormat("yyyyMMdd").format(message.getCreateDate()));
		// 必填-页大小
		request.setPageSize(1L);
		// 必填-当前页码从1开始计数
		request.setCurrentPage(1L);
		// hint 此处可能会抛出异常,注意catch
		QuerySendDetailsResponse querySendDetailsResponse = acsClient.getAcsResponse(request);
		// 获取返回结果
		if (SUCCESS.equals(querySendDetailsResponse.getCode())) {
			List<SmsSendDetailDTO> list = querySendDetailsResponse.getSmsSendDetailDTOs();
			if (CollectionUtils.isEmpty(list)) {
				if (Duration.between(message.getCreateDate().toInstant(), Instant.now()).toMinutes() > 5) {
					return new QuerySendResult(true, Columns.SendStatus.FAILURE, null, null, "noMatchSendRecord");
				} else {
					logger.info("未查询到对应的短信记录,可能是因为阿里读写库同步延迟");
					return new QuerySendResult(false);
				}
			}
			SmsSendDetailDTO smsSendDetailDTO = list.get(0);
			logger.info("阿里云通讯短信查询结果为:{}", new ObjectMapper().writeValueAsString(smsSendDetailDTO));
			int aliSendStatus = smsSendDetailDTO.getSendStatus().intValue();// 1:等待回执,2:发送失败,3:发送成功
			byte sendStatus = Columns.SendStatus.SENDING;
			Date receiveDate = null;
			String failCode = null;
			if (aliSendStatus == 2) {
				sendStatus = Columns.SendStatus.FAILURE;
				failCode = smsSendDetailDTO.getErrCode();
			} else if (aliSendStatus == 3) {
				receiveDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")// 2017-05-25 00:00:00
						.parse(smsSendDetailDTO.getReceiveDate());
				sendStatus = Columns.SendStatus.SUCCESS;
			}
			return new QuerySendResult(true, sendStatus, smsSendDetailDTO.getContent(), receiveDate,
					failCode);
		} else {
			return new QuerySendResult(false);
		}
	} catch (Exception e) {
		logger.error("阿里云通讯查询短信接口异常", e);
		return new QuerySendResult(false);
	}
}