com.github.qcloudsms.httpclient.HTTPException Java Examples
The following examples show how to use
com.github.qcloudsms.httpclient.HTTPException.
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: TencentSmsSender.java From BigDataPlatform with GNU General Public License v3.0 | 6 votes |
@Override public SmsResult sendWithTemplate(String phone, int templateId, String[] params) { try { SmsSingleSenderResult result = sender.sendWithParam("86", phone, templateId, params, "", "", ""); logger.debug(result); SmsResult smsResult = new SmsResult(); smsResult.setSuccessful(true); smsResult.setResult(result); return smsResult; } catch (HTTPException | IOException e) { logger.error(e.getMessage(), e); } return null; }
Example #2
Source File: TencentSmsSender.java From dts-shop with GNU Lesser General Public License v3.0 | 6 votes |
@Override public SmsResult send(String phone, String content) { try { SmsSingleSenderResult result = sender.send(0, "86", phone, content, "", ""); logger.debug(result); SmsResult smsResult = new SmsResult(); smsResult.setSuccessful(true); smsResult.setResult(result); return smsResult; } catch (HTTPException | IOException e) { e.printStackTrace(); } return null; }
Example #3
Source File: TencentSmsSender.java From dts-shop with GNU Lesser General Public License v3.0 | 6 votes |
@Override public SmsResult sendWithTemplate(String phone, int templateId, String[] params) { try { SmsSingleSenderResult result = sender.sendWithParam("86", phone, templateId, params, "", "", ""); logger.debug(result); SmsResult smsResult = new SmsResult(); smsResult.setSuccessful(true); smsResult.setResult(result); return smsResult; } catch (HTTPException | IOException e) { e.printStackTrace(); } return null; }
Example #4
Source File: TencentSmsSender.java From mall with MIT License | 6 votes |
@Override public SmsResult send(String phone, String content) { try { SmsSingleSenderResult result = sender.send(0, "86", phone, content, "", ""); logger.debug(result); SmsResult smsResult = new SmsResult(); smsResult.setSuccessful(true); smsResult.setResult(result); return smsResult; } catch (HTTPException | IOException e) { e.printStackTrace(); } return null; }
Example #5
Source File: TencentSmsSender.java From mall with MIT License | 6 votes |
@Override public SmsResult sendWithTemplate(String phone, int templateId, String[] params) { try { SmsSingleSenderResult result = sender.sendWithParam("86", phone, templateId, params, "", "", ""); logger.debug(result); SmsResult smsResult = new SmsResult(); smsResult.setSuccessful(true); smsResult.setResult(result); return smsResult; } catch (HTTPException | IOException e) { e.printStackTrace(); } return null; }
Example #6
Source File: TencentSmsSender.java From BigDataPlatform with GNU General Public License v3.0 | 6 votes |
@Override public SmsResult send(String phone, String content) { try { SmsSingleSenderResult result = sender.send(0, "86", phone, content, "", ""); logger.debug(result); SmsResult smsResult = new SmsResult(); smsResult.setSuccessful(true); smsResult.setResult(result); return smsResult; } catch (HTTPException | IOException e) { logger.error(e.getMessage(), e); } return null; }
Example #7
Source File: SmsSingleSender.java From qcloudsms_java with MIT License | 5 votes |
public SmsSingleSenderResult sendWithParam(String nationCode, String phoneNumber, int templateId, String[] params, String sign, String extend, String ext) throws HTTPException, JSONException, IOException { return sendWithParam(nationCode, phoneNumber, templateId, new ArrayList<String>(Arrays.asList(params)), sign, extend, ext); }
Example #8
Source File: SmsSingleSender.java From qcloudsms_java with MIT License | 5 votes |
/** * 指定模板单发 * * @param nationCode 国家码,如 86 为中国 * @param phoneNumber 不带国家码的手机号 * @param templateId 信息内容 * @param params 模板参数列表,如模板 {1}...{2}...{3},那么需要带三个参数 * @param sign 签名,如果填空,系统会使用默认签名 * @param extend 扩展码,可填空 * @param ext 服务端原样返回的参数,可填空 * @return {@link}SmsSingleSenderResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public SmsSingleSenderResult sendWithParam(String nationCode, String phoneNumber, int templateId, ArrayList<String> params, String sign, String extend, String ext) throws HTTPException, JSONException, IOException { long random = SmsSenderUtil.getRandom(); long now = SmsSenderUtil.getCurrentTime(); JSONObject body = new JSONObject() .put("tel", (new JSONObject()).put("nationcode", nationCode).put("mobile", phoneNumber)) .put("sig", SmsSenderUtil.calculateSignature(appkey, random, now, phoneNumber)) .put("tpl_id", templateId) .put("params", params) .put("sign", sign) .put("time", now) .put("extend", SmsSenderUtil.isNotEmpty(extend) ? extend : "") .put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) .addHeader("Conetent-Type", "application/json") .addQueryParameter("sdkappid", this.appid) .addQueryParameter("random", random) .setConnectionTimeout(60 * 1000) .setRequestTimeout(60 * 1000) .setBody(body.toString()); try { // May throw IOException and URISyntaxexception HTTPResponse res = httpclient.fetch(req); // May throw HTTPException handleError(res); // May throw JSONException return (new SmsSingleSenderResult()).parseFromHTTPResponse(res); } catch(URISyntaxException e) { throw new RuntimeException("API url has been modified, current url: " + url); } }
Example #9
Source File: SmsSingleSender.java From qcloudsms_java with MIT License | 5 votes |
/** * 普通单发 * * 普通单发短信接口,明确指定内容,如果有多个签名,请在内容中以【】的方式添加到信息内容中,否则系统将使用默认签名 * * @param type 短信类型,0 为普通短信,1 营销短信 * @param nationCode 国家码,如 86 为中国 * @param phoneNumber 不带国家码的手机号 * @param msg 信息内容,必须与申请的模板格式一致,否则将返回错误 * @param extend 扩展码,可填空 * @param ext 服务端原样返回的参数,可填空 * @return {@link}SmsSingleSenderResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public SmsSingleSenderResult send(int type, String nationCode, String phoneNumber, String msg, String extend, String ext) throws HTTPException, JSONException, IOException { long random = SmsSenderUtil.getRandom(); long now = SmsSenderUtil.getCurrentTime(); JSONObject body = new JSONObject() .put("tel", (new JSONObject()).put("nationcode", nationCode).put("mobile", phoneNumber)) .put("type", type) .put("msg", msg) .put("sig", SmsSenderUtil.calculateSignature(this.appkey, random, now, phoneNumber)) .put("time", now) .put("extend", SmsSenderUtil.isNotEmpty(extend) ? extend : "") .put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) .addHeader("Conetent-Type", "application/json") .addQueryParameter("sdkappid", this.appid) .addQueryParameter("random", random) .setConnectionTimeout(60 * 1000) .setRequestTimeout(60 * 1000) .setBody(body.toString()); // TODO Handle timeout exception try { // May throw IOException and URISyntaxexception HTTPResponse res = httpclient.fetch(req); // May throw HTTPException handleError(res); // May throw JSONException return (new SmsSingleSenderResult()).parseFromHTTPResponse(res); } catch(URISyntaxException e) { throw new RuntimeException("API url has been modified, current url: " + url); } }
Example #10
Source File: SmsMultiSender.java From qcloudsms_java with MIT License | 5 votes |
public SmsMultiSenderResult sendWithParam(String nationCode, String[] phoneNumbers, int templateId, String[] params, String sign, String extend, String ext) throws HTTPException, JSONException, IOException { return sendWithParam(nationCode, new ArrayList<String>(Arrays.asList(phoneNumbers)), templateId, new ArrayList<String>(Arrays.asList(params)), sign, extend, ext); }
Example #11
Source File: SmsMultiSender.java From qcloudsms_java with MIT License | 5 votes |
/** * 指定模板群发 * * @param nationCode 国家码,如 86 为中国 * @param phoneNumbers 不带国家码的手机号列表 * @param templateId 模板 id * @param params 模板参数列表 * @param sign 签名,如果填空,系统会使用默认签名 * @param extend 扩展码,可以填空 * @param ext 服务端原样返回的参数,可以填空 * @return {@link}SmsMultiSenderResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public SmsMultiSenderResult sendWithParam(String nationCode, ArrayList<String> phoneNumbers, int templateId, ArrayList<String> params, String sign, String extend, String ext) throws HTTPException, JSONException, IOException { long random = SmsSenderUtil.getRandom(); long now = SmsSenderUtil.getCurrentTime(); JSONObject body = new JSONObject() .put("tel", toTel(nationCode, phoneNumbers)) .put("sign", sign) .put("tpl_id", templateId) .put("params", params) .put("sig", SmsSenderUtil.calculateSignature(appkey, random, now, phoneNumbers)) .put("time", now) .put("extend", SmsSenderUtil.isNotEmpty(extend) ? extend : "") .put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) .addHeader("Conetent-Type", "application/json") .addQueryParameter("sdkappid", this.appid) .addQueryParameter("random", random) .setConnectionTimeout(60 * 1000) .setRequestTimeout(60 * 1000) .setBody(body.toString()); try { // May throw IOException and URISyntaxexception HTTPResponse res = httpclient.fetch(req); // May throw HTTPException handleError(res); // May throw JSONException return (new SmsMultiSenderResult()).parseFromHTTPResponse(res); } catch (URISyntaxException e) { throw new RuntimeException("API url has been modified, current url: " + url); } }
Example #12
Source File: SmsMultiSender.java From qcloudsms_java with MIT License | 5 votes |
public SmsMultiSenderResult send(int type, String nationCode, String[] phoneNumbers, String msg, String extend, String ext) throws HTTPException, JSONException, IOException { return send(type, nationCode, new ArrayList<String>(Arrays.asList(phoneNumbers)), msg, extend, ext); }
Example #13
Source File: SmsMultiSender.java From qcloudsms_java with MIT License | 5 votes |
/** * 普通群发 * * 明确指定内容,如果有多个签名,请在内容中以【】的方式添加到信息内容中,否则系统将使用默认签名 * * @param type 短信类型,0 为普通短信,1 营销短信 * @param nationCode 国家码,如 86 为中国 * @param phoneNumbers 不带国家码的手机号列表 * @param msg 信息内容,必须与申请的模板格式一致,否则将返回错误 * @param extend 扩展码,可填空 * @param ext 服务端原样返回的参数,可填空 * @return {@link}SmsMultiSenderResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public SmsMultiSenderResult send(int type, String nationCode, ArrayList<String> phoneNumbers, String msg, String extend, String ext) throws HTTPException, JSONException, IOException { long random = SmsSenderUtil.getRandom(); long now = SmsSenderUtil.getCurrentTime(); JSONObject body = new JSONObject(); body.put("tel", toTel(nationCode, phoneNumbers)) .put("type", type) .put("msg", msg) .put("sig", SmsSenderUtil.calculateSignature(appkey, random, now, phoneNumbers)) .put("time", now) .put("extend", SmsSenderUtil.isNotEmpty(extend) ? extend : "") .put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) .addHeader("Conetent-Type", "application/json") .addQueryParameter("sdkappid", this.appid) .addQueryParameter("random", random) .setConnectionTimeout(60 * 1000) .setRequestTimeout(60 * 1000) .setBody(body.toString()); try { // May throw IOException and URISyntaxexception HTTPResponse res = httpclient.fetch(req); // May throw HTTPException handleError(res); // May throw JSONException return (new SmsMultiSenderResult()).parseFromHTTPResponse(res); } catch(URISyntaxException e) { throw new RuntimeException("API url has been modified, current url: " + url); } }
Example #14
Source File: VoiceFileUploader.java From qcloudsms_java with MIT License | 5 votes |
/** * 上传语音文件 * * @param fileContent 语音文件内容 * @param contentType 语音文件类型 * @return {@link}VoiceFileUploaderResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public VoiceFileUploaderResult upload(byte[] fileContent, ContentType contentType) throws HTTPException, JSONException, IOException { long random = SmsSenderUtil.getRandom(); long now = SmsSenderUtil.getCurrentTime(); String fileSha1Sum = SmsSenderUtil.sha1sum(fileContent); String auth = SmsSenderUtil.calculateAuth(this.appkey, random, now, fileSha1Sum); String type; if (contentType == ContentType.WAV) { type = "audio/wav"; } else { type = "audio/mpeg"; } HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) .addHeader("Content-Type", type) .addHeader("x-content-sha1", fileSha1Sum) .addHeader("Authorization", auth) .addQueryParameter("sdkappid", this.appid) .addQueryParameter("random", random) .addQueryParameter("time", now) .setConnectionTimeout(60 * 1000) .setRequestTimeout(60 * 1000) .setBody(new String(fileContent, StandardCharsets.ISO_8859_1)) .setBodyCharset(StandardCharsets.ISO_8859_1); try { // May throw IOException and URISyntaxexception HTTPResponse res = httpclient.fetch(req); // May throw HTTPException handleError(res); // May throw JSONException return (new VoiceFileUploaderResult()).parseFromHTTPResponse(res); } catch(URISyntaxException e) { throw new RuntimeException("API url has been modified, current url: " + url); } }
Example #15
Source File: SmsMobileStatusPuller.java From qcloudsms_java with MIT License | 5 votes |
public SmsStatusPullReplyResult pullReply(String nationCode, String mobile, long beginTime, long endTime, int max) throws HTTPException, JSONException, IOException { // May throw IOException HTTPResponse res = pull(1, nationCode, mobile, beginTime, endTime, max); // May throw HTTPException handleError(res); // May throw JSONException return (new SmsStatusPullReplyResult()).parseFromHTTPResponse(res); }
Example #16
Source File: SmsMobileStatusPuller.java From qcloudsms_java with MIT License | 5 votes |
public SmsStatusPullCallbackResult pullCallback(String nationCode, String mobile, long beginTime, long endTime, int max) throws HTTPException, JSONException, IOException { // May throw IOException HTTPResponse res = pull(0, nationCode, mobile, beginTime, endTime, max); // May throw HTTPException handleError(res); // May throw JSONException return (new SmsStatusPullCallbackResult()).parseFromHTTPResponse(res); }
Example #17
Source File: SmsVoicePromptSender.java From qcloudsms_java with MIT License | 5 votes |
/** * 发送语音短信 * * @param nationCode 国家码,如 86 为中国 * @param phoneNumber 不带国家码的手机号 * @param prompttype 类型,目前固定值为2 * @param playtimes 播放次数 * @param msg 语音通知消息内容 * @param ext "扩展字段,原样返回" * @return {@link}SmsVoicePromptSenderResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public SmsVoicePromptSenderResult send(String nationCode, String phoneNumber, int prompttype, int playtimes, String msg, String ext) throws HTTPException, JSONException, IOException { long random = SmsSenderUtil.getRandom(); long now = SmsSenderUtil.getCurrentTime(); JSONObject body = new JSONObject() .put("tel", (new JSONObject()).put("nationcode", nationCode).put("mobile", phoneNumber)) .put("prompttype", prompttype) .put("promptfile", msg) .put("playtimes", playtimes) .put("sig", SmsSenderUtil.calculateSignature(this.appkey, random, now, phoneNumber)) .put("time", now) .put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) .addHeader("Conetent-Type", "application/json") .addQueryParameter("sdkappid", this.appid) .addQueryParameter("random", random) .setConnectionTimeout(60 * 1000) .setRequestTimeout(60 * 1000) .setBody(body.toString()); try { // May throw IOException and URISyntaxexception HTTPResponse res = httpclient.fetch(req); // May throw HTTPException handleError(res); // May throw JSONException return (new SmsVoicePromptSenderResult()).parseFromHTTPResponse(res); } catch(URISyntaxException e) { throw new RuntimeException("API url has been modified, current url: " + url); } }
Example #18
Source File: SmsVoiceVerifyCodeSender.java From qcloudsms_java with MIT License | 5 votes |
/** * 发送语音短信 * * @param nationCode 国家码,如 86 为中国 * @param phoneNumber 不带国家码的手机号 * @param msg 消息类型 * @param playtimes 播放次数 * @param ext 服务端原样返回的参数,可填空 * @return {@link}SmsVoiceVerifyCodeSenderResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public SmsVoiceVerifyCodeSenderResult send(String nationCode, String phoneNumber, String msg, int playtimes, String ext) throws HTTPException, JSONException, IOException { long random = SmsSenderUtil.getRandom(); long now = SmsSenderUtil.getCurrentTime(); JSONObject body = new JSONObject(); body.put("tel", (new JSONObject()).put("nationcode", nationCode).put("mobile", phoneNumber)) .put("msg", msg) .put("playtimes", playtimes) .put("sig", SmsSenderUtil.calculateSignature(this.appkey, random, now, phoneNumber)) .put("time", now) .put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) .addHeader("Conetent-Type", "application/json") .addQueryParameter("sdkappid", this.appid) .addQueryParameter("random", random) .setConnectionTimeout(60 * 1000) .setRequestTimeout(60 * 1000) .setBody(body.toString()); try { // May throw IOException HTTPResponse res = httpclient.fetch(req); // May throw HTTPException handleError(res); // May throw JSONException return (new SmsVoiceVerifyCodeSenderResult()).parseFromHTTPResponse(res); } catch(URISyntaxException e) { throw new RuntimeException("API url has been modified, current url: " + url); } }
Example #19
Source File: TtsVoiceSender.java From qcloudsms_java with MIT License | 5 votes |
public TtsVoiceSenderResult send(String nationCode, String phoneNumber, int templateId, String[] params, int playtimes, String ext) throws HTTPException, JSONException, IOException { return send(nationCode, phoneNumber, templateId, new ArrayList<String>(Arrays.asList(params)), playtimes, ext); }
Example #20
Source File: TtsVoiceSender.java From qcloudsms_java with MIT License | 5 votes |
/** * 指定模板发送语音短信 * * @param nationCode 国家码,如86为中国 * @param phoneNumber 不带国家码的手机号 * @param templateId 信息内容 * @param params 模板参数列表 * @param playtimes 播放次数 * @param ext 扩展字段,原样返回 * @return {@link}TtsVoiceSenderResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public TtsVoiceSenderResult send(String nationCode, String phoneNumber, int templateId, ArrayList<String> params, int playtimes, String ext) throws HTTPException, JSONException, IOException { long random = SmsSenderUtil.getRandom(); long now = SmsSenderUtil.getCurrentTime(); JSONObject body = new JSONObject() .put("tel", (new JSONObject()).put("nationcode", nationCode).put("mobile", phoneNumber)) .put("tpl_id", templateId) .put("params", params) .put("playtimes", playtimes) .put("sig", SmsSenderUtil.calculateSignature(this.appkey, random, now, phoneNumber)) .put("time", now) .put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) .addHeader("Conetent-Type", "application/json") .addQueryParameter("sdkappid", this.appid) .addQueryParameter("random", random) .setConnectionTimeout(60 * 1000) .setRequestTimeout(60 * 1000) .setBody(body.toString()); try { // May throw IOException and URISyntaxexception HTTPResponse res = httpclient.fetch(req); // May throw HTTPException handleError(res); // May throw JSONException return (new TtsVoiceSenderResult()).parseFromHTTPResponse(res); } catch(URISyntaxException e) { throw new RuntimeException("API url has been modified, current url: " + url); } }
Example #21
Source File: FileVoiceSender.java From qcloudsms_java with MIT License | 5 votes |
/** * 发送文件语音 * * @param nationCode 国家码,如 86 为中国 * @param phoneNumber 不带国家码的手机号 * @param fid 语音文件fid * @param playtimes 播放次数 * @param ext 扩展字段,原样返回 * @return {@link}FileVoiceSenderResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public FileVoiceSenderResult send(String nationCode, String phoneNumber, String fid, int playtimes, String ext) throws HTTPException, JSONException, IOException { long random = SmsSenderUtil.getRandom(); long now = SmsSenderUtil.getCurrentTime(); JSONObject body = new JSONObject() .put("tel", (new JSONObject()).put("nationcode", nationCode).put("mobile", phoneNumber)) .put("fid", fid) .put("playtimes", playtimes) .put("sig", SmsSenderUtil.calculateSignature(this.appkey, random, now, phoneNumber)) .put("time", now) .put("ext", SmsSenderUtil.isNotEmpty(ext) ? ext : ""); HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) .addHeader("Conetent-Type", "application/json") .addQueryParameter("sdkappid", this.appid) .addQueryParameter("random", random) .setConnectionTimeout(60 * 1000) .setRequestTimeout(60 * 1000) .setBody(body.toString()); try { // May throw IOException and URISyntaxexception HTTPResponse res = httpclient.fetch(req); // May throw HTTPException handleError(res); // May throw JSONException return (new FileVoiceSenderResult()).parseFromHTTPResponse(res); } catch(URISyntaxException e) { throw new RuntimeException("API url has been modified, current url: " + url); } }
Example #22
Source File: VoiceFileStatus.java From qcloudsms_java with MIT License | 5 votes |
/** * 查询语音文件审核状态 * * @param fid 语音文件fid * @return {@link}VoiceFileStatusResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public VoiceFileStatusResult get(String fid) throws HTTPException, JSONException, IOException { long random = SmsSenderUtil.getRandom(); long now = SmsSenderUtil.getCurrentTime(); JSONObject body = new JSONObject() .put("fid", fid) .put("sig", SmsSenderUtil.calculateFStatusSignature( this.appkey, random, now, fid)) .put("time", now); HTTPRequest req = new HTTPRequest(HTTPMethod.POST, this.url) .addHeader("Conetent-Type", "application/json") .addQueryParameter("sdkappid", this.appid) .addQueryParameter("random", random) .setConnectionTimeout(60 * 1000) .setRequestTimeout(60 * 1000) .setBody(body.toString()); try { // May throw IOException and URISyntaxexception HTTPResponse res = httpclient.fetch(req); // May throw HTTPException handleError(res); // May throw JSONException return (new VoiceFileStatusResult()).parseFromHTTPResponse(res); } catch(URISyntaxException e) { throw new RuntimeException("API url has been modified, current url: " + url); } }
Example #23
Source File: SmsStatusPuller.java From qcloudsms_java with MIT License | 5 votes |
/** * 拉取回复信息 * * @param max 最大条数, 最多100 * @return {@link}SmsStatusPullReplyResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public SmsStatusPullReplyResult pullReply(int max) throws HTTPException, JSONException, IOException { // May throw IOException HTTPResponse res = pull(1, max); // May throw HTTPException handleError(res); // May throw JSONException return (new SmsStatusPullReplyResult()).parseFromHTTPResponse(res); }
Example #24
Source File: SmsStatusPuller.java From qcloudsms_java with MIT License | 5 votes |
/** * 拉取回执结果 * * @param max 最大条数, 最多100 * @return {@link}SmsStatusPullCallbackResult * @throws HTTPException http status exception * @throws JSONException json parse exception * @throws IOException network problem */ public SmsStatusPullCallbackResult pullCallback(int max) throws HTTPException, JSONException, IOException { // May throw IOException HTTPResponse res = pull(0, max); // May throw HTTPException handleError(res); // May throw JSONException return (new SmsStatusPullCallbackResult()).parseFromHTTPResponse(res); }
Example #25
Source File: SmsBase.java From qcloudsms_java with MIT License | 3 votes |
/** * Handle http status error * * @param response raw http response * @return response raw http response * @throws HTTPException http status exception */ public HTTPResponse handleError(HTTPResponse response) throws HTTPException { if (response.statusCode < 200 || response.statusCode >= 300) { throw new HTTPException(response.statusCode, response.reason); } return response; }