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. ...
随机推荐
- heartFunction c语言
#include <stdio.h> int main(int argc, char *argv[]) { float y,x,z,f; for(y = 1.5f;y > -1.5f ...
- Tomcat配置文件入门
转自:http://blog.csdn.net/jubincn/article/details/4856293 Tomcat 基本配置 tomcat读取配置文件 首先简单说一下tomcat是如何读取配 ...
- 单元测试系列之十:Sonar 常用代码规则整理(二)
摘要:帮助公司部署了一套sonar平台,经过一段时间运行,发现有一些问题出现频率很高,因此有必要将这些问题进行整理总结和分析,避免再次出现类似问题. 作者原创技术文章,转载请注明出处 ======== ...
- CSDN去广告插件
因为避免不了与代码打交道,所以经常要上网搜代码,一般搜索到的资源都指向了CSDN,然而,好好的一篇博文,上面有很多广告,看着很不舒服,冲vip是不可能的,穷的的要死,怎么办呢?写个插件把! 去广告原理 ...
- mysql基础篇(上篇)
一.数据库 1.数据库介绍 2.RDBMS专业术语 3.MySQL数据库 4.常用数据库命令 1.数据库介绍 :什么是数据库 数据库就是按照数据结构来组织.存储和管理数据的仓库. 我们常常讲的数据库往 ...
- 【python 3】 函数 初识
函数初识 1.函数的定义.调用.返回值 函数的定义.调用.返回值 def demo(): ## 定义函数 (def + 空格 + 函数名 + () + 冒号) ## 如下为函数体 return a # ...
- web优化及web安全攻防学习总结
web优化 前端:(高性能网站建设进阶指南) 使用gzip压缩(节省服务器的 网络带宽) 减少http请求( 减少DNS请求所耗费的时间. 减少服务器压力. 减少http请求头) 使用cdn(用户可以 ...
- git删除文件夹
git rm 要删除的文件夹 -r -f git commit -m 'del config' git push 使用场景,删除test文件夹,本来在码云上,正常的文件夹右击会出现 ...
- R语言 重命名目录下所有文件
myfilepath <- "F:/paper2/climateExposure/wjj_mec/second/paths/" setwd(myfilepath) allty ...
- b/s 和c/s的区别
简单解释: B/S最大优势为客户端免维护,适用于用户群庞大,或客户需求经长发生变化的情况. C/S功能强大,可以减轻服务器端压力,如果用户的需求特别复杂,用C/S. 全面: Client/Server ...