功能简介
注册登录
账户管理
资费标准
在线充值
接口规范
开发例程
经典应用
成功案例
技术支持
联系我们
ASP
|
ASP.NET
|
PHP
|
CGI
|
VB
|
VB.NET
|
VC
|
C++
|
C#
|
DELPHI
|
JAVA
|
JSP
|
FLASH
|
C++ BUILDER
|
POWER BUILDER
|
JBUILDER
ASP - 短信发送开发例程
<% function SmsGate(byval SmsUserName,byval SmsPassWord,byval CustomMobile,byval SmsMsg) '调用晴朗短信网关(SMSGATE.CN)接口发送短信 '后续参数依次为您在晴朗短信网关的用户名、密码、接收短信的手机号码集、短信内容 '返回True表示全部或部分发送成功,返回False表示所有短信均发送失败 '本函数版本号:v0.5 if len(Server.URLEncode("码"))>7 then SmsUrl="utf" else SmsUrl="gb" SmsUrl="http://www.smsgate.cn/" & SmsUrl & ".asp" SmsData="usr=" & Server.URLEncode(SmsUserName) & "&pwd=" & Server.URLEncode(SmsPassWord) & "&tel=" & Server.URLEncode(CustomMobile) & "&msg=" & Server.URLEncode(SmsMsg) SmsData=GetHttpPage(SmsUrl,SmsData,"",1) if SmsData<>"" and isnumeric(SmsData) then SmsGate=-SmsData<0 else SmsGate=False end function Function GetHttpPage(ByVal SourseUrl,ByVal PostData,ByVal SoursePageCharSet,ByVal CSType) '读取HTTP页面内容(网址,POST数据[空表示GET],编码,0-C/1-S) 'v0.4 On Error Resume Next If SoursePageCharSet="" Then SoursePageCharSet="GB2312" If CSType Then Set HttpObj=Server.CreateObject("MSXML2.ServerXMLHTTP") Else Set HttpObj=Server.CreateObject("MSXML2.XMLHTTP") If PostData="" Then HttpObj.Open "GET",SourseUrl,False HttpObj.Send() Else HttpObj.Open "POST",SourseUrl,False HttpObj.SetRequestHeader "Content-Type","application/x-www-form-urlencoded" HttpObj.Send PostData End If If Err.Number Then GetHttpPage="" Else If HttpObj.ReadyState=4 Then GetHttpPage=BytesToBSTR(HttpObj.ResponseBody,SoursePageCharSet) Else GetHttpPage="" End if End if Set HttpObj=Nothing End Function Function BytesToBstr(byval body,byval SoursePageCharSet) '二进制流转字符串(数据流,源编码) 'v0.2 dim objstream if SoursePageCharSet="" then SoursePageCharSet="GB2312" set objstream=Server.CreateObject("adodb.stream") objstream.Type=1 objstream.Mode=3 objstream.Open objstream.Write body objstream.Position=0 objstream.Type=2 objstream.Charset=SoursePageCharSet BytesToBstr=objstream.ReadText objstream.Close set objstream=nothing End Function '以上函数可粘贴到您的程序中直接复用,无须做任何修改 '以下代码为调用上述函数的示例,您可以在自己的程序中酌情模仿 dim myusername,mypassword,telephone,message,smsstate '您的用户名 myusername="myusername" '您在短信网关的登录密码 mypassword="test" '接收短信的手机号码集,多个号码之间用分号分隔 telephone="08256662151;13558979637" '需要发送的短信内容 message="短信测试" if SmsGate(myusername,mypassword,telephone,message) then response.write "发送成功!" else response.write "发送失败!" end if %>
ASP - 短信接收开发例程
<% '短信网关SMSGATE.CN短信接收演示程序 '本代码中的三处“7FG48HGF76PBFM”是我胡乱设置的校验码,实际使用时应该替换为任意其他字符 '使用时,需将本段代码保存为一个ASP文件,上传到服务器 '并在您的短信网关账户中,把您的短信回复通知接口地址设置为:“本页面的URL绝对地址?verifycode=7FG48HGF76PBFM” '赋初始值(默认为接收失败,返回“0”) received=0 '比较校验码,检查信息真伪 if request.querystring("verifycode")="7FG48HGF76PBFM" then '取得各参数数据 telephone=request.querystring("mob") locating=request.querystring("loc") messagetext=request.querystring("msg") servicenumber=request.querystring("srv") receivetime=request.querystring("tim") '判断各数据的合法性 if isnumeric(telephone) and telephone<>"" and messagetext<>"" and isnumeric(servicenumber) and servicenumber<>"" and isdate(receivetime) and locating<>"" then '对接收到的数据进行自己的处理,本例为保存到当前目录下的一个文本文件“myreceive.txt”中 on error resume next set fso=server.createobject("scripting.filesystemobject") Set fsofile=fso.OpenTextFile(Server.MapPath("myreceive.txt"),8,true) fsofile.writeline receivetime & vbtab & servicenumber & vbtab & telephone & "(" & locating & ")" & vbtab & messagetext fsofile.close Set fsofile=Nothing Set fso=Nothing '检查接收过程中是否还有其他不明错误发生 if err.number=0 then '接收成功,返回“1” received=1 '关闭各条件语句 end if end if end if '输出处理结果代码 response.write received %>
ASP - 余额查询开发例程
<% function smsbalance(byval myusername) '取得某账户在SMSGATE.CN的短信余额(您的注册手机号码) '返回一个整数值表示查询成功,该整数值就是您的短信余额 '如果查询失败,本函数将返回0.1 '版本号:v0.0.3 on error resume next Dim objHttpRequest,backvalue if len(Server.URLEncode("码"))>7 then URL="ubal" else URL="gbal" URL="http://www.smsgate.cn/" & URL & ".asp?usr=" & Server.URLEncode(myusername) set objHttpRequest=CreateObject("MSXML2.ServerXMLHTTP") if objHttpRequest is Nothing Then smsbalance=0.1 else objHttpRequest.open "GET",URL,False objHttpRequest.send() if objHttpRequest.status<>200 then smsbalance=0.1 else backvalue=objHttpRequest.responseText if isnumeric(backvalue) then smsbalance=cdbl(backvalue) else smsbalance=0.1 end if end if Set objHttpRequest=Nothing end function '以上函数可直接在您的程序中复用,无需进行任何修改 '以下代码为针对上述函数的调用范例,在您的程序中应酌情修改 myusername="myusername" mybalance=smsbalance(myusername) if instr(mybalance,".") then response.write "查询失败!" else response.write myusername & "的当前短信余额为" & mybalance & "条" end if %>
功能简介
|
免费注册
|
在线发送
|
资费标准
|
付款方式
|
索取发票
|
接口规范
|
开发例程
|
经典应用
|
成功案例
|
联系我们
版权所有:
四川射洪晴朗软件有限责任公司
©2021
蜀ICP备05031908号
营业执照:
510922000018264
机构代码:
69919469-6
电话:0825-6662151,13778745236 传真:0825-6662151 技术支持时间:早8点~晚8点(节假日不休) 系统服务:永不间断
晴朗旗下网站:
通信设备商城
,
短信发送系统
,
通信服务业万能中间件
,
空中充值系统
,
盯盘专家
,
虚拟主机专卖店
川公网安备 51092202000058号