asp调用短信接口实现用户注册
前几天做一个asp语言开发的网站需要实现用户注册短信验证功能,就研究了一下如何实现,简单给大家分享下调用过程。
首先需要找到一个第三方短信接口,当时用的是动力思维乐信的短信接口。
首先需要先注册个动力思维乐信平台账号,这个后面要用到,可以到他们官网注册(http://www.lx598.com/)
这里贴出来他们的短信接口接入文档说明(http://www.lx598.com/apitext.html),和asp语言的demo(http://www.lx598.com/aspCode.html)
前端用户注册页面(这个比较简单)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>发送短信</title>
</head>
<body>
<hr />
<form name="form1" action="index4.asp" method="post" >
发送短信<br />
用户名:
<input name="AccountName" type="text" />
密码:
<input name="Password" type="password" />
<br />
内容:
<input name="message" type="text" />
目标号码:
<input name="mobiles" type="text" />
<input name="submit"type="submit" value="提交" />
<input name="reset"type="reset" value="重置" />
<input name="cd" type="hidden" value="4" />
<input name="batchNumber" type="hidden" value="<%=now()%>" />
</form>
</body>
</html>
后台代码
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>发送短信</title> </head> <body>
<!--#include file="md5.asp"-->
<%
Function BytesToBstr(body,code)
dim objstream
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 =code
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%> <%
'response.ContentType="text/xml;charset=UTF-8"
dim cdkey1,password1,cd
dim HttpReq,str,url
dim cpname,cpadrr,cplinkman,cpphone,cpmobile,cpfax,cpmail,cppost,cpworks,manager
cd=request.Form("cd")
cmd=request.Form("cmd")
cdkey1=request.Form("AccountName")
password1=UCase(md5(request.Form("password"))) cpname=request.Form("cpname")
cpadrr=request.Form("cpadrr")
cplinkman=request.Form("cplinkman")
cpphone=request.Form("cpphone")
cpmobile=request.Form("cpmobile")
cpfax=request.Form("cpfax")
cpmail=request.Form("cpmail")
cppost=request.Form("cppost")
cpworks=request.Form("cpworks")
manager=request.Form("manager") url="cmd="+cmd+"&AccountName="+cdkey1+"&Password="+password1 if cd="1" then
Set HttpReq = Server.CreateObject("Microsoft.XMLHTTP")
HttpReq.open "post", "http://116.255.135.146/WebClient", False,"",""
HttpReq.setRequestHeader "Content-Length",len(url)
HttpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HttpReq.send(url)
'str=HttpReq.responseXML
if inStr(BytesToBstr(HttpReq.responseBody,"UTF-8"),"<") then
Set XMLDOC = Server.CreateObject("Microsoft.XMLDOM")
XMLDOC.async = false
XMLDOC.loadxml(BytesToBstr(HttpReq.responseBody,"UTF-8"))
set XMLDOCElement=XMLDOC.documentElement
dimResultStr1=XMLDOCElement.SelectSingleNode("//reply/ErrorCode").text
set objnodes=Nothing
Set XMLDOC = Nothing
else
dimResultStr1=dimThisSmsState1
end if
if dimResultStr1=0 then
response.write "发送成功"
else
response.write "发送失败"
end if
'response.Write str
end if
%>
<br /> <%
Function UrlEncoding(DataStr)
Dim StrReturn,Si,ThisChr,InnerCode,Hight8,Low8
StrReturn = ""
For Si = 1 To Len(DataStr)
ThisChr = Mid(DataStr,Si,1)
If Abs(Asc(ThisChr)) < &HFF Then
StrReturn = StrReturn & ThisChr
Else
InnerCode = Asc(ThisChr)
If InnerCode < 0 Then
InnerCode = InnerCode + &H10000
End If
Hight8 = (InnerCode And &HFF00)\ &HFF
Low8 = InnerCode And &HFF
StrReturn = StrReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
UrlEncoding = StrReturn
End Function %> <% if cd="4" then
mobiles=request.Form("mobiles")
content=request.Form("message")
cmd1=request.Form("cmd")
batch=replace(request.Form("batchNumber"),"-","0")
batchNumber=replace(batch,":","")
batchNumber=replace(batchNumber," ","")
batchNumber=left(batchNumber,15)
url="accName="+cdkey1+"&accPwd="+password1+"&aimcodes="+mobiles+"&content="+content+"【签名】
Set HttpReq = Server.CreateObject("Microsoft.XMLHTTP")
HttpReq.open "post", "http://www.lx198.com/sdk/send", False,"",""
HttpReq.setRequestHeader "Content-Length",len(url)
HttpReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"
url=URLEncoding(url)
HttpReq.send(url)
str=HttpReq.responseText
response.Write str
end if
%> </body>
</html>
asp调用短信接口实现用户注册的更多相关文章
- 发送短信验证码及调用短信接口与C# 后台 post 发送
#region 调用短信接口 public ActionResult Mobile(string Tel)//调用接口 { Random rm = new Random(); int i; strin ...
- C#调用短信接口(通过简单的工厂模式整合多个短信平台)
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...
- http请求,HttpClient,调用短信接口
项目中安全设置找回密码的功能,需要通过发送短信验证绑定手机,通过绑定的手机号验证并重新设置密码. 因为项目是通过maven管理的,所以需要在pom.xml文件中引入jar包, maven引入的jar包 ...
- nginx限制IP恶意调用短信接口处理方法
真实案例: 查看nginx日志,发现别有用心的人恶意调用API接口刷短信: /Jun/::: +] "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) ...
- C# 调用短信接口
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...
- java代码实现调用短信接口,发送短信验证。
一.代码示例 package com.aaa.zxf.login; import org.apache.commons.httpclient.HttpClient; import org.apache ...
- 调用短信接口,先var_dump()看数据类型是object需要json_decode(json_encode( $resp),true)转换成array
返回的数据.先看类型,如果是object类型 先json_encode, 再json_decode,加true 转换成数组 $resp = $c->execute($req); var_dump ...
- asp.net mvc短信接口调用——阿里大于API开发心得
互联网上有许多公司提供短信接口服务,诸如网易云信.阿里大于等等.我在自己项目里需要使用到短信服务起到通知作用,实际开发周期三天,完成配置.开发和使用,总的说,阿里大于提供的接口易于开发,非常的方便,短 ...
- asp.net两种方式的短信接口使用(提供接口的都是收费的)
一种是http请求的方式,另一种就是提供WebService接口供调用的. //服务商 sms.webchinese.cn //sms_url="http://sms.webchinese. ...
随机推荐
- ejs常用功能函数
利用<%- include filename %>加载其他页面模版: 1.缓存功能,能够缓存已经解析好的html模版: 2.<% code %>用于执行其中javascript ...
- vue+vux页面滚动定位(支持上下滑动)
接上篇文章:https://www.cnblogs.com/ligulalei/p/10622778.html在上篇文章中实现了通过使用scrollIntoView()在使用vux的移动端实现了点击锚 ...
- Request method 'PUT'/ 'POST' not supported
起因 在项目中遇到需要进行crud操作的功能,用的是Springboot+MybatisPlus+MySQL+AVue,在通过postman测试接口正确性时遇到此错误. 排查过程 因为项目运行是没问题 ...
- 洛谷 P3376 【【模板】网络最大流】
题目描述 如题,给出一个网络图,以及其源点和汇点,求出其网络最大流. 输入 第一行包含四个正整数N.M.S.T,分别表示点的个数.有向边的个数.源点序号.汇点序号. 接下来M行每行包含三个正整数ui. ...
- h5 ios键盘卡死页面
失去焦点以后重新设置页面顶部位置 $('input,textarea').on('blur',function(){ window.scroll(0,0); }); $('select').on('c ...
- BASE64加解密
- JDK 自带 - Commons Codec 地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi - Bou ...
- python 学习笔记 5 ----> dive into python 3
字符串 文本:屏幕上显示的字符或者其他的记号 计算机认识的东西:位(bit)和字节(byte) 文本的本质:某种字符编码方式保存的内容. 字符编码:一种映射(显示的内容 ----> 内存.磁盘 ...
- 如何增加亚马逊listing多个类目节点
流量是电商销售的必要因素,可以说,任何成功的电商平台都离不开流量.亚马逊listing优化做得好,不仅能提高产品的曝光率,还能提升转换率,而好的类目可以吸引大的流量.帮你快速爬升. 首先我们来了解一下 ...
- sysbench工具安装使用
一.sysbench简介 Sysbench是一款开源的.跨平台的.模块化的.多线程的性能测试工具,通过高负载地运行在数据库上,可以执行CPU.内存.线程.IO.数据库等方面的性能测试.用于评估操作系统 ...
- mac os x 编译spark-2.1.0 for hadoop-2.7.3
mac os x maven编译spark-2.1.0 for hadoop-2.7.3 1.官方文档中要求安装Maven 3.3.9+ 和Java 8 ; 2.执行 export ...