前几天做一个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调用短信接口实现用户注册的更多相关文章

  1. 发送短信验证码及调用短信接口与C# 后台 post 发送

    #region 调用短信接口 public ActionResult Mobile(string Tel)//调用接口 { Random rm = new Random(); int i; strin ...

  2. C#调用短信接口(通过简单的工厂模式整合多个短信平台)

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...

  3. http请求,HttpClient,调用短信接口

    项目中安全设置找回密码的功能,需要通过发送短信验证绑定手机,通过绑定的手机号验证并重新设置密码. 因为项目是通过maven管理的,所以需要在pom.xml文件中引入jar包, maven引入的jar包 ...

  4. nginx限制IP恶意调用短信接口处理方法

    真实案例: 查看nginx日志,发现别有用心的人恶意调用API接口刷短信: /Jun/::: +] "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) ...

  5. C# 调用短信接口

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net ...

  6. java代码实现调用短信接口,发送短信验证。

    一.代码示例 package com.aaa.zxf.login; import org.apache.commons.httpclient.HttpClient; import org.apache ...

  7. 调用短信接口,先var_dump()看数据类型是object需要json_decode(json_encode( $resp),true)转换成array

    返回的数据.先看类型,如果是object类型 先json_encode, 再json_decode,加true 转换成数组 $resp = $c->execute($req); var_dump ...

  8. asp.net mvc短信接口调用——阿里大于API开发心得

    互联网上有许多公司提供短信接口服务,诸如网易云信.阿里大于等等.我在自己项目里需要使用到短信服务起到通知作用,实际开发周期三天,完成配置.开发和使用,总的说,阿里大于提供的接口易于开发,非常的方便,短 ...

  9. asp.net两种方式的短信接口使用(提供接口的都是收费的)

    一种是http请求的方式,另一种就是提供WebService接口供调用的. //服务商 sms.webchinese.cn //sms_url="http://sms.webchinese. ...

随机推荐

  1. SpringBoot Tomcat启动报错

    中间的桥梁就是下面这个依赖 <dependency> <groupId>org.slf4j</groupId> <artifactId>jcl-over ...

  2. enum & json 之间的转换

    enum 转为 string:EnumMember & StringEnumConverter public enum CampaignStatus : Int32 { [EnumMember ...

  3. MVVM以及vue的双向绑定

    原文:https://www.cnblogs.com/onepixel/p/6034307.html MVVM 是Model-View-ViewModel 的缩写,它是一种基于前端开发的架构模式,其核 ...

  4. 【GO】【LiteIDE】

    https://blog.csdn.net/qq_32034593/article/details/82986311 下载地址:https://www.golangtc.com/download/li ...

  5. mysql自增长主键,删除数据后,将主键顺序重新排序

    用数据库的时候,难免会删除数据,会发现设置的主键增长不是按照正常顺序排列,中间有断隔比如这样. 以我这个情况举例 处理方法的原理:删除原有的自增ID,重新建立新的自增ID. ALTER TABLE ` ...

  6. UNDO(二)

    Managing Undo Beginning with Release 11g, for a default installation, Oracle Database automatically ...

  7. C语言实验一(2)

    #include<stdio.h>int main(){ char c1,c2; c1=97; c2=98; printf("c1=%c,c2=%c\n",c1,c2) ...

  8. jquary高级和ajax

    jquary高级: 1.动画 1.三种方式显示与隐藏元素 1.默认显示和隐藏的方式 1.show([speed],[easing],[fn]):显示 [speed],[easing],[fn] spe ...

  9. 使用session统计在线人数

    效果图如下 这里是Chrome浏览器新登录一个用户 代码展示 package com.test.Util; import java.util.ArrayList; import javax.servl ...

  10. 【javascript】数据类型中的一些小知识点

    1. undefined 和 null undefined是一个变量而不是一个关键字,所以可以被重新赋值.为了避免歧义,一般推荐用void 0 来获取undefined: null是一个关键字,所以可 ...