伊人看片_1204国产成人精品视频_国产成人精品免费_最新中文字幕久久_日本久久视频_国产精品成人一区二区

用戶體驗中心
售前咨詢:400-006-0086 客服QQ:400-006- 0086 投訴電話:152-5606-8386
創瑞通訊平臺(網頁版):客戶登錄 | 免費試用 | 常見問題 | 客服中心
您當前位置:創瑞 >> 行業新聞 >> 瀏覽文章行業新聞
java實現短信驗證碼

使用創瑞短信平臺接口,模擬post請求,調用創瑞短信平臺提供的接口,實現短信驗證碼調用功能,下發短信驗證碼。

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
/*
功能: web.cr6868.com HTTP接口 發送短信
說明: http://web.cr6868.com/asmx/smsservice.aspx?name=登錄名&pwd=接口密碼
&mobile=手機號碼&content=內容&sign=簽名&stime=發送時間&type=pt&extno=自定義擴展碼
*/


public class xioo {
public static void main(String[] args) throws Exception {
// 用戶名
String name="wbxxx";
// 密碼
String pwd="0C759A360WWBD5F5E0F5FF9F0597";
// 電話號碼字符串,中間用英文逗號間隔
StringBuffer mobileString=new StringBuffer("");
// 內容字符串
StringBuffer contextString=new StringBuffer("短信內容");
// 簽名
String sign="簽名";
// 追加發送時間,可為空,為空為及時發送
String stime="";
// 擴展碼,必須為數字 可為空
StringBuffer extno=new StringBuffer();
System.out.println(doPost(name, pwd, mobileString, contextString, sign, stime, extno));
}



/**
* 發送短信
* 
* @param name 用戶名
* @param pwd 密碼
* @param mobileString 電話號碼字符串,中間用英文逗號間隔
* @param contextString 內容字符串
* @param sign 簽名
* @param stime 追加發送時間,可為空,為空為及時發送
* @param extno 擴展碼,必須為數字 可為空
* @return 
* @throws Exception
*/



public static String doPost(String name, String pwd,
StringBuffer mobileString, StringBuffer contextString,
String sign, String stime, StringBuffer extno) throws Exception {
StringBuffer param = new StringBuffer();


param.append("name="+name);
param.append("&pwd="+pwd);
param.append("&mobile=").append(mobileString);
param.append("&content=").append(URLEncoder.encode(contextString.toString(),"UTF-8"));
param.append("&stime="+stime);
param.append("&sign=").append(URLEncoder.encode(sign,"UTF-8"));
param.append("&type=pt");
param.append("&extno=").append(extno);


URL localURL = new URL("http://web.cr6868.com/asmx/smsservice.aspx?");
URLConnection connection = localURL.openConnection();
HttpURLConnection httpURLConnection = (HttpURLConnection)connection;
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty("Accept-Charset", "utf-8");
httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
httpURLConnection.setRequestProperty("Content-Length", String.valueOf(param.length()));
OutputStream outputStream = null;
OutputStreamWriter outputStreamWriter = null;
InputStream inputStream = null;
InputStreamReader inputStreamReader = null;
BufferedReader reader = null;
String resultBuffer = "";

try {
outputStream = httpURLConnection.getOutputStream();
outputStreamWriter = new OutputStreamWriter(outputStream);
outputStreamWriter.write(param.toString());
outputStreamWriter.flush();

if (httpURLConnection.getResponseCode() >= 300) {
throw new Exception
("HTTP Request is not success, Response code is " + httpURLConnection.getResponseCode());
inputStream = httpURLConnection.getInputStream();

resultBuffer = convertStreamToString(inputStream);
}

 finally {
if (outputStreamWriter != null) {
outputStreamWriter.close();
}
if (outputStream != null) {
outputStream.close();
}
if (reader != null) {
reader.close();
}
if (inputStreamReader != null) {
inputStreamReader.close();
}
if (inputStream != null) {
inputStream.close();
}
}

return resultBuffer;
}
/**
* 轉換返回值類型為UTF-8格式.
* @param is
* @return
*/

public static String convertStreamToString(InputStream is) {
StringBuilder sb1 = new StringBuilder();
byte[] bytes = new byte[4096];
int size = 0;
try {
while ((size = is.read(bytes)) > 0) {
String str = new String(bytes, 0, size, "UTF-8");
sb1.append(str);
}
} 
catch (IOException e) {
e.printStackTrace();
} 

finally {
try {
is.close();
} 
catch (IOException e) {
e.printStackTrace();

}
}
return sb1.toString();
}
}

Php短信接口代碼

C#短信接口代碼

Delphi短信接口代碼

點擊下載更多短信接口代碼

返回首頁
上一篇:短信驗證碼平臺
下一篇:點爆營銷靠神馬?短信推廣打先鋒

更多詳情請搜索:
推薦產品
熱門產品
 
 
  • 創瑞新浪微博
  • 創瑞-搜狐公眾平臺
  • 創瑞企業QQ
創瑞微信二維碼
掃描二維碼
關注創瑞更多精彩
 
 
 
增值電信業務經營許可證 | 計算機軟件著作權證書 | 軟件測評中心-登記測試證書 | 短消息服務接入代碼使用證書
開戶許可證 | 營業執照 | 會員證書 | 網站地圖
短信平臺 | 短信接口 | 語音驗證碼 | 國際短信 | 短信公眾號
地址:中國·合肥高新區長江西路與科學大道交叉口5F創業園A座502#
Copyright 2005-2017 安徽創瑞信息技術有限公司 增值電信業務經營許可證:B2-20120248
網站備案:皖ICP備12004788號-11 創瑞公安備案皖公網安備 34019202000075號
主站蜘蛛池模板: 在线色网 | 中文日韩在线 | 人成久久 | 黄色免费电影网站 | 欧美视频精品在线观看 | 欧美一区二区三区四区不卡 | 国内久久久久久 | 亚洲精品乱码久久久久久蜜糖图片 | 在线免费观看激情视频 | 激情久久久 | 日本一区二区视频免费观看 | 色乱码一区二区三区网站 | 久久精品中文字幕 | 亚洲国产成人av好男人在线观看 | 精品国产一区二区三区高潮视 | 欧美成人精品一区二区三区 | 亚洲婷婷综合网 | 国产精品一区二区久久 | 在线视频不卡一区 | 成人在线视频观看 | 在线观看成人av | 激情视频网 | 欧美大片一区二区 | 亚洲视频在线观看 | 亚洲视频一区 | 免费一区二区 | av网站在线免费观看 | 奇米影视7777 | 亚洲一区在线视频 | 国产欧美日韩在线观看 | 国产精品免费精品自在线观看 | 91在线视频导航 | 中文字幕在线观看 | 国产成人在线看 | 国产精品自拍视频网站 | 国产成人精品一区二区三区网站观看 | 亚洲视频1区 | 国产资源在线看 | 鲁一鲁综合 | 卡通动漫第一页 | 人人草天天草 |