为方便大家使用,除了API接口类文件外(agentxmlclient.inc.asp),我们提供了部分常用函数供大家调用,这些函数存放在api文件夹下的两个文件(smsbase.inc.asp 和 xmlbase.inc.asp)中。下面以发送SMS短信的返回信息(XML格式)来具体说明这些函数的用法。 |
<?xml version="1.0" encoding="GB2312" ?>
- <scp xmlns="urn:mobile:params:xml:ns:scp-1.0" xmlns:sms="urn:todaynic.com:sms" xmlns:user="urn:todaynic.com:user">
- <command>
<action>SMS:sendSMS</action>
<sms:mobile>13700000000</sms:mobile>
<sms:message>YQ==</sms:message>
<sms:datetime>2006-08-03 15:14</sms:datetime>
<sms:smstype>0</sms:smstype>
<sms:smsabout />
<sms:sender />
</command>
- <security>
<smsuser>ms1166</smsuser>
<cltrid>11545892936905</cltrid>
<login>4c61535b0932433c9441a6868a40b5a4</login>
</security>
</scp> |
|
一、getCode()方法 |
<?
respxml=newclient.sendSMS(t_pho,t_msg,t_time)
SESSION("xml")=newclient.sendXML
SESSION("respxml")=respxml
code=newclient.getCode()
?>
使用该方法可以得到四位数的code信息。不同的数字代表不同不同的含义,具体如下
2000 "Command complateted successfully" //操作成功
3000 "Datebase error"//数据库错误(插入\删除等)
4000 "Client error"//客户未知错误
4001 "Xml parse error"//xml错误
4002 "Authorization error"//授权错误(用户不存在、密码错误、权限不足等)
4003 "No data post to server"
4004 "Object does not exist"//函数不存在
4300 "Account error"//财务错误
4400 "Parameter error"//参数错误
5000 "Server error"
5001 "Unable connet to remote server"
5002 "Server no data return"
5003 "Server other error"
6000 "optation error"//操作错误,如不能添加、删除文件等 |
|
二、responseXML成员 |
<?
Set newclient=New Domain
.......
respxml=newclient.sendSMS(t_pho,t_msg,t_time)
SESSION("xml")=newclient.sendXML
SESSION("respxml")=respxml
code=newclient.getCode()
idmessage=getMessage(respxml,"idmessage")
msg=getMessage(respxml,"msg")
successnum=getMessage(respxml,"successnum")
successphone=getMessage(respxml,"successphone")
failephone=getMessage(respxml,"failephone")
iFSuccess=isSuccess(respxml)
?>
该成员保存的是完整的返回XML信息。 |
三、sendXML成员 |
<?
Set newclient=New Domain
dim t_pho,t_msg,t_time
t_pho=REQUEST("PhoneNum")
t_msg=enCode_base64(REQUEST("msg"))
t_time=REQUEST("dtTime")
respxml=newclient.sendSMS(t_pho,t_msg,t_time)
SESSION("xml")=newclient.sendXML
SESSION("respxml")=respxml
code=newclient.getCode()
...........
iFSuccess=isSuccess(respxml);
?>
该成员保存的是完整的发送XML信息。 |
四、函数说明 |
发送短信
sendSMS(t_pho,t_msg,t_time,apitype)
参数:t_pho - 要接收短信的手机号码,多个手机号码用“,”分隔;
t_msg - 短信内容,一条短信最大长度,视所选择的通道而不同。(通道二:64个字;即时通道:50个字)
t_time - 短信发送的时间(值为空或比当前时间小即是即时发送)。
apitype - 短信发送通道。( 0:默认通道; 2:通道二; 3:即时通道)
返回:服务器返回的XML, 如respxml=newclient.sendSMS()
用getMessage(respxml,"msg")方法得到提示信息,如成功的提示:"Command complateted successfully"
successphone=getMessage(respxml,"successphone") - 发送成功的手机号码
failephone=getMessage(respxml,"failephone") - 发送失败的手机号码
successnum=getMessage(respxml,"successnum") - 成功发送的手机号码个数
idmessage=getMessage(respxml,"idmessage") - 短信编号
|
查询短信账户余额
infoSMSAccount()
返回:服务器端返回的XML, 如respxml=newclient.infoSMSAccount()
用getMessage(respxml,"msg")方法得到提示信息,如成功的提示:"Command complateted successfully"
用getMessage(respxml,"smsaccount")方法得到账户余额,单位为条数
|
回复短信查询
readSMS()
返回:服务器返回的XML, 如respxml=newclient.readSMS()
用getMessage(respxml,"msg")方法得到提示信息,如成功的提示:"Command complateted successfully"
返回变量:
id - 回复短信ID,大于0表示有回复短信,小于等于0表示失败
src - 回复手机
dst - 接收对象,参考值
time - 回复时间,格式如0000-00-00 00:00:00
message - 回复内容,为base64加密后的字符串,需解码
err - 错误信息,成功则为空,参考值
|
|
|
|