短信驗(yàn)證碼接口文檔
2018-04-16 00:00:00
來源:
點(diǎn)擊:5728
喜歡:0
嘉之元云通信為客戶提供優(yōu)質(zhì)驗(yàn)證碼短信,營銷短信、國際短信;國際直連通道可群發(fā)短信至任何國家和地區(qū),其短信驗(yàn)證碼、短信營銷等106短信接口已服務(wù)了近兩萬家企業(yè),提供短信接口API,幫助客戶快速接入!
以下是短信接口文檔,接口系統(tǒng)訪問地址:smsapi.jzyyun.com:9003 大家也可以在下載欄里面下載:
第一部分:http 接口
1. SMS發(fā)送接口
http://系統(tǒng)訪問地址/servlet/UserServiceAPI?method=sendSMS&isLongSms=0&username=test&password=zadlll&smstype=1&extenno=123&mobile=13866194295,15375427702&content=短信測試
采用 POST方式提交參數(shù):
參數(shù)定義如下:
method 值為 sendSMS 發(fā)送短信
username 明文用戶名
password 密碼采用BASE64 加密算法
smstype 發(fā)送短信的類型: 值為0,1,2 O-卡發(fā) 1-網(wǎng)關(guān) 2-會員
mobile 手機(jī)號碼采用英文狀態(tài)下逗號,分割, 最大2萬個(gè)號碼
content 為發(fā)送內(nèi)容 采用GBK 進(jìn)行URLENCODE
isLongSms 0-普通短信 1-加長短信
extenno 為通道擴(kuò)展子號碼,可以為空
返回值:如果成功返回success;批號ID 否則返回failure;錯(cuò)誤提示
2.查看用戶賬號信息接口
http://系統(tǒng)訪問地址/servlet/UserServiceAPI?method=getRestMoney&username=tes&password=BASE64(password)
建議采用 POST方式提交參數(shù):
參數(shù)定義如下:
method 值為 getRestMoney 獲得用戶賬號信息,可發(fā)短信數(shù)量
username 明文用戶名
password=BASE64(password) 密碼采用BASE64 加密算法
返回值:如果成功返回帳號剩余短信數(shù)量字符串:如memberSmsNum=684;gateSmsNum=49919;kaSmsNum=49964
memberSmsNum=684 表示會員帳號剩余短信數(shù)量
gateSmsNum=49919 表示網(wǎng)關(guān)帳號剩余短信數(shù)量
kaSmsNum=49964 表示卡發(fā)帳號剩余短信數(shù)量
如果失敗返回如:failure;錯(cuò)誤提示
3.獲取下行狀態(tài)報(bào)告接口
http://系統(tǒng)訪問地址/servlet/UserServiceAPI?method=getSmsReport&username=test&password=BASE64(password)
method 值為 getSmsReport 獲得用戶賬號信息,可發(fā)短信數(shù)量
username 明文用戶名
password=BASE64(password) 密碼采用BASE64 加密算法
返回值:如果成功則返回XML格式的狀態(tài)報(bào)告信息
如果失敗返回如:failure;錯(cuò)誤提示
XML節(jié)點(diǎn)定義如下
smsreport XML根節(jié)點(diǎn)
psreport 子節(jié)點(diǎn),一個(gè)節(jié)點(diǎn)對應(yīng)一個(gè)下行狀態(tài)報(bào)告
mobile 手機(jī)號
username 用戶名
smslogid 批號ID,發(fā)送成功返回的ID號
status 發(fā)送返回的狀態(tài) 1 代表成功 0-失敗 2-不明
sendtime 發(fā)送時(shí)間
返回如下格式:
<?xmlversion="1.0" encoding="utf-8" ?>
-<smsreport>
-<psreport>
<mobile>15275427712</mobile>
<username>admin</username>
<smslogid>66</smslogid>
<status>1</status>
<sendtime>2012-08-16 01:05:39.0</sendtime>
</psreport>
-<psreport>
<mobile>13865193295</mobile>
<username>admin</username>
<smslogid>66</smslogid>
<status>1</status>
<sendtime>2012-08-16 01:04:07.0</sendtime>
</psreport>
-<psreport>
<mobile>15375427702</mobile>
<username>admin</username>
<smslogid>67</smslogid>
<status>1</status>
<sendtime>2012-08-16 01:03:07.0</sendtime>
</psreport>
-<psreport>
<mobile>13866194295</mobile>
<username>admin</username>
<smslogid>67</smslogid>
<status>1</status>
<sendtime>2012-08-16 01:01:27.0</sendtime>
</psreport>
</smsreport>
4.上行回復(fù)接口
http://系統(tǒng)訪問地址/servlet/UserServiceAPI?method=getRecvSMS&username=test&password=BASE64(password)
返回值:如果成功則返回XML格式的狀態(tài)報(bào)告信息
如果失敗返回如:failure;錯(cuò)誤提示
XML節(jié)點(diǎn)定義如下
smsrerecv XML根節(jié)點(diǎn)
psrerecv 子節(jié)點(diǎn),一個(gè)節(jié)點(diǎn)對應(yīng)一個(gè)上行回復(fù)信息
mobile 手機(jī)號
receiver 接受人
content 回復(fù)內(nèi)容采用BASE64編碼
sendtime 接收時(shí)間
返回如下格式XML:
<?xmlversion="1.0" encoding="utf-8" ?>
-<smsrerecv>
-<psrerecv>
<mobile>15256560065</mobile>
<receiver>admin</receiver>
<content>xOPLrbChPw==</content>
<sendtime>2012-06-18 14:56:00.0</sendtime>
</psrerecv>
-<psrerecv>
<mobile>13866194285</mobile>
<receiver>admin</receiver>
<content>u9jP8w==</content>
<sendtime>2012-06-15 21:43:25.0</sendtime>
</psrerecv>
</smsrerecv>
5.修改密碼接口
http://系統(tǒng)訪問地址/servlet/UserServiceAPI?method=updatePassword &username=test&password=123&newPassword=122
username 登陸用戶名
password 原密碼
newPassword 新密碼 注意密碼為英文和字母組合
返回值:1-修改密碼成功 2-修改密碼失敗 3-用戶不存在 4-未知錯(cuò)誤
JAVA 調(diào)用范例
BASE64 加密算法方法:
/**
* encode a specified string useing BASE64Encoder
*
* @param str
* the string to beencoded
* @return String
* @throws Exception
*/
public synchronized static String BASE64Encoder(String str) throws
Exception {
return new sun.misc.BASE64Encoder().encode(str.getBytes());
}
下載OPACHE 的HttpClient包
HttpClient client = newHttpClient();
client.getHostConfiguration().setHost("http://系統(tǒng)訪問地址", "80");
PostMethodpost = new PostMethod("/servlet/UserServiceAPI");
NameValuePair method = newNameValuePair("method","sendSMS");
NameValuePair smstype= newNameValuePair("smstype","1");
NameValuePair username = newNameValuePair("username", "dddb");
NameValuePairpassword= new NameValuePair("password", Util
.BASE64Encoder("1223"));//密碼采用BASE64加密
NameValuePairmobile = new NameValuePair("mobile","13866194295,15266144263");
NameValuePair content= newNameValuePair("content", "test content");
post.setRequestBody(newNameValuePair[] { method,username,password,mobile,content});
intstatus = client.executeMethod(post);
post.releaseConnection();
JAVA.NET.URL
try{
String u = "http://系統(tǒng)訪問地址/servlet/UserServiceAPI?method=sendSMS&username=test&password="+BASE64Encoder("123")+"&smstype=1&mobile=13866194295,15375427702&content=短信測試";
URLurl = new URL(u);
conn= (HttpURLConnection)url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setUseCaches(false);
conn.setRequestProperty("Content-type","application/x-www-form-urlencoded");
conn.setRequestProperty("Connection","Close");
conn.setRequestProperty("Content-length",String.valueOf(params.length()));
conn.setDoInput(true);
conn.connect();
OutputStreamWriterout = new OutputStreamWriter(conn.getOutputStream(), "GBK");
out.write(params.toString());
out.flush();
out.close();
InputStreamin = conn.getInputStream();
InputStreamReaderr = new InputStreamReader(in);
LineNumberReaderdin = new LineNumberReader(r);
Stringline = null;
StringBuffersb = new StringBuffer();
while((line=din.readLine())!=null)
{
sb.append(line+"");
}
//對返回結(jié)果解析sb.toString
}catch(Exception e){
}
ASP調(diào)用示例:
BASE64加密:
Public Function Base64_Encode(bstrSource)
Const BASE64_TABLE ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim strTempLine
Dim j
If bstrSource = "" Then
bstrSource = " "
End If
For j = 1 To (Len(bstrSource) - Len(bstrSource) Mod 3) Step 3
strTempLine = strTempLine + Mid(BASE64_TABLE, (asc(Mid(bstrSource, j,1)) 4) + 1, 1)
strTempLine = strTempLine + Mid(BASE64_TABLE, ((asc(Mid(bstrSource, j,1)) Mod 4) * 16 _
+ asc(Mid(bstrSource, j +1, 1)) 16) + 1, 1)
strTempLine = strTempLine + Mid(BASE64_TABLE, ((asc(Mid(bstrSource, j +1, 1)) Mod 16) * 4 _
+ asc(Mid(bstrSource, j +2, 1)) 64) + 1, 1)
strTempLine = strTempLine + Mid(BASE64_TABLE, (asc(Mid(bstrSource, j +2, 1)) Mod 64) + 1, 1)
Next
If Not (Len(bstrSource) Mod 3) = 0 Then
If (Len(bstrSource) Mod 3) = 2 Then
strTempLine = strTempLine + Mid(BASE64_TABLE, (asc(Mid(bstrSource, j,1)) 4) + 1, 1)
strTempLine = strTempLine + Mid(BASE64_TABLE, (asc(Mid(bstrSource, j,1)) Mod 4) * 16 _
+ asc(Mid(bstrSource, j +1, 1)) 16 + 1, 1)
strTempLine = strTempLine + Mid(BASE64_TABLE, (asc(Mid(bstrSource, j +1, 1)) Mod 16) * 4 + 1, 1)
strTempLine = strTempLine & "="
ElseIf (Len(bstrSource) Mod 3) = 1 Then
strTempLine = strTempLine + Mid(BASE64_TABLE, asc(Mid(bstrSource, j, 1)) 4 + 1, 1)
strTempLine = strTempLine + Mid(BASE64_TABLE, (asc(Mid(bstrSource, j,1)) Mod 4) * 16 + 1, 1)
strTempLine = strTempLine & "=="
End If
End If
Base64_Encode= strTempLine
End Function
'以下是調(diào)用核心代碼
url="http://系統(tǒng)訪問地址/servlet/UserServiceAPI?method=sendSMS&username=1test&password="&ufmBase64_Encode("123456")&"&smstype=2&content=短信測試"
url=url&"&mobile=13866194295"
sethttp=Server.createobject("Microsoft.XMLHTTP")
Http.open "POST",url,false
http.setRequestHeader "Content-Length",len(mobile)
http.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
Http.send(mobile)
'獲得返回結(jié)果
response.write http.responseText
'對返回結(jié)果處理,如果返回結(jié)果為success表示成功,,返回failure;錯(cuò)誤提示表示調(diào)用失敗
如URL為:http://系統(tǒng)訪問地址/servlet/UserServiceAPI?method=sendSMS&username=115&password=MTIzNDU2&smstype=2&mobile=13866194295,15375427702&content=短信測試
這里賬號為115343785 密碼為123456 ,MTIzNDU2為123456進(jìn)行加密后的字符串,smsType=2為會員發(fā)送為0卡發(fā) 為1網(wǎng)關(guān)
第二部分: web service 接口
WEB SERVICE 接口地址為:站點(diǎn)地址+/services/userApi?wsdl 如: http://系統(tǒng)訪問地址/services/userApi?wsdl
1. SMS發(fā)送接口
String sendSms(String username, String password, int smstype,
Stringcontent, String mobile,int isLongSms )
參數(shù)定義如下:
username 明文用戶名
password=BASE64(password) 密碼采用BASE64 加密算法
smstype 發(fā)送短信的類型: 值為0,1,2 O-卡發(fā) 1-網(wǎng)關(guān) 2-會員
mobile 手機(jī)號碼采用英文狀態(tài)下逗號,分割
content 為發(fā)送內(nèi)容
返回值:如果成功返回success 否則返回failure;錯(cuò)誤提示
2.查看用戶賬號信息接口
String getRestMoney(String username, Stringpassword)
參數(shù)定義如下:
method 值為 getRestMoney 獲得用戶賬號信息,可發(fā)短信數(shù)量
username 明文用戶名
password=BASE64(password) 密碼采用BASE64 加密算法
返回值:如果成功返回帳號剩余短信數(shù)量字符串:如memberSmsNum=684;gateSmsNum=49919;kaSmsNum=49964
memberSmsNum=684 表示會員帳號剩余短信數(shù)量
gateSmsNum=49919 表示網(wǎng)關(guān)帳號剩余短信數(shù)量
kaSmsNum=49964 表示卡發(fā)帳號剩余短信數(shù)量
如果失敗返回如:failure;錯(cuò)誤提示
3.獲取狀態(tài)報(bào)告接口
String getSmsReport(String username, Stringpassword)
參數(shù)定義如下:
username 明文用戶名
password=BASE64(password) 密碼采用BASE64 加密算法
成功返回 XML 格式字符串,格式同HTTP
4.返回回復(fù)信息
String getRecvSMS(String username, Stringpassword)
參數(shù)定義如下:
username 明文用戶名
password=BASE64(password) 密碼采用BASE64 加密算法
成功返回 XML 格式字符串,格式同HTTP
上一篇:短信驗(yàn)證碼短信平臺常見的幾個(gè)問題及解決辦法
下一篇:智能電話營銷機(jī)器人話術(shù)制作要點(diǎn)