| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 417 人关注过本帖
标题:分享一下asp短信接口源码
只看楼主 加入收藏
tigerbook
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-3-28
收藏
 问题点数:0 回复次数:0 
分享一下asp短信接口源码
最近在做手机验证的时候,需要用到短信接口,程序是asp写的,但弄了很长时间,还是发送乱码,现在终于弄好了,把源码给分享一下,虽然很简单,但是asp实在不常用啊.
短信的速度还是挺不错的.需要的朋友们可以参考一下.


reg.asp

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>56短信网短信接口(http://www.)</title>
<script src="js/jquery.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript">
function get(obj) {
    var partten = /^\d{10,13}$/;
    if (!partten.test(document.getElementById("t_tel").value)) {
        alert('请输入正确的手机号码');
        return;
    }
  obj.disabled = true;
  $.ajax({
      url: "sms.asp",
      type: "Post",
      data: "Tel=" + $("#t_tel").val(),
      success: function(msg) {
          obj.disabled = false;
          if (msg == "ok") {
              alert("短信已经发送成功")
              return;
          }
          if (msg == "error") {
              alert("短信发送失败")
              return;
          }
          //alert(msg);//用来调试
      }
  })
  
}
</script>
</head>
<body>
<label>
<form id="form1" name="form1" method="post" action="reg.asp?action=add">
您手机号码:
<input name="t_tel" type="text" id="t_tel" />      
<input id="Button1" type="button" value="获取验证码" onClick="get(this)" />
<br />
<br />
验证码:
<input name="t_num" type="text" id="t_num" />
</label>
<br />
<br />
<label>
<input type="submit" name="Submit" value=" 确 定 " />
</label>
</form>
<p>&nbsp;</p>
</body>
</html>



sms.asp
<%

Function getHTTPPage(url)
 Dim Http
    Set Http = Server.CreateObject("MSXML2.XMLHTTP")
        Http.Open "GET", url, False
        Http.send()
        If Http.readystate <> 4 Then
            Exit Function
        End If
        getHTTPPage = BytesToBstr(Http.responseBody, "GB2312")
    Set Http = Nothing
    If Err.Number <> 0 Then Err.Clear
End Function

Function BytesToBstr(body, Cset)
 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 = Cset
        BytesToBstr = objstream.ReadText
        objstream.Close
    Set objstream = Nothing
End Function



'调用短信接口网址官方网站:http://www.
Function SendSms(smsMob,smsText)
'response.Write(smsMob)
'response.End()
   SmsServer="http://jiekou.   
   userid="60"
   username1="test1"
   userpwd="qwqwqw"
   usersms="1061"
  
   SenData=SmsServer&"comid="&userid&"&username="&username1&"&userpwd="&userpwd&"&handtel="&smsMob&"&sendcontent="&smsText&"&sendtime=&smsnumber="&usersms
 
   qwe=getHTTPPage(SenData)
  'response.Write(qwe)

If qwe = "1" then '发送成功
Response.Write("ok")
Else '发送失败
 Response.Write("error")
 'Response.Write(qwe)//参考56短信网:http://www. 接口文档  
End if
 

End Function

if   request("Tel")<>"" then
    call SendSms(request("Tel"),"手机号的发送内容")
    Else '发送失败
    Response.Write("error")
end if


%>
搜索更多相关主题的帖子: 短信接口 html content PUBLIC title 
2012-03-28 20:26
快速回复:分享一下asp短信接口源码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017434 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved