国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > Java > 正文

Java調(diào)取創(chuàng)藍(lán)253短信驗(yàn)證碼的實(shí)現(xiàn)代碼

2024-07-13 10:17:36
字體:
供稿:網(wǎng)友

基于創(chuàng)藍(lán)253短信服務(wù)平臺(tái)的Java調(diào)用短信接口API

package com.bcloud.msg.http;import java.io.ByteArrayOutputStream;import java.io.InputStream;import java.net.URLDecoder;import org.apache.commons.httpclient.HttpClient;import org.apache.commons.httpclient.HttpStatus;import org.apache.commons.httpclient.NameValuePair;import org.apache.commons.httpclient.URI;import org.apache.commons.httpclient.methods.GetMethod;     /**     *     * @param url 應(yīng)用地址,類似于http://ip:port/msg/     * @param account 賬號(hào)     * @param pswd 密碼     * @param mobile 手機(jī)號(hào)碼,多個(gè)號(hào)碼使用","分割     * @param msg 短信內(nèi)容     * @param needstatus 是否需要狀態(tài)報(bào)告,需要true,不需要false     * @return 返回值定義參見HTTP協(xié)議文檔     * @throws Exception     */     public static String batchSend(String url, String account, String pswd, String mobile, String msg,              boolean needstatus, String extno) throws Exception {          HttpClient client = new HttpClient();          GetMethod method = new GetMethod();          try {              URI base = new URI(url, false);              method.setURI(new URI(base, "HttpBatchSendSM", false));              method.setQueryString(new NameValuePair[] {                        new NameValuePair("account", account),                        new NameValuePair("pswd", pswd),                        new NameValuePair("mobile", mobile),                        new NameValuePair("needstatus", String.valueOf(needstatus)),                        new NameValuePair("msg", msg),                        new NameValuePair("extno", extno),                   });              int result = client.executeMethod(method);              if (result == HttpStatus.SC_OK) {                   InputStream in = method.getResponseBodyAsStream();                   ByteArrayOutputStream baos = new ByteArrayOutputStream();                   byte[] buffer = new byte[1024];                   int len = 0;                   while ((len = in.read(buffer)) != -1) {                        baos.write(buffer, 0, len);                   }                   return URLDecoder.decode(baos.toString(), "UTF-8");              } else {                   throw new Exception("HTTP ERROR Status: " + method.getStatusCode() + ":" + method.getStatusText());              }          } finally {              method.releaseConnection();          }     }}

總結(jié)

以上所述是小編給大家介紹的Java調(diào)取創(chuàng)藍(lán)253短信驗(yàn)證碼的實(shí)現(xiàn)代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VeVb武林網(wǎng)網(wǎng)站的支持!


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到JAVA教程頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 垦利县| 齐齐哈尔市| 仲巴县| 南陵县| 厦门市| 镇宁| 杨浦区| 额尔古纳市| 会昌县| 平南县| 华亭县| 万州区| 江山市| 广宁县| 商丘市| 东山县| 汝州市| 巧家县| 河间市| 托克托县| 景泰县| 兰西县| 富裕县| 信阳市| 潼关县| 元谋县| 海淀区| 武功县| 资源县| 金门县| 多伦县| 西平县| 毕节市| 方正县| 柯坪县| 临江市| 浦东新区| 浦东新区| 昌乐县| 涿州市| 金川县|