php 短信接口源码,虽然简单,还是实用的.分享一下
此实例,主要是调用短信接口,实现手机验证的问题,基本上解决了手机乱码的问题,短信的发送速度也挺好的,需要用到php短信接口的朋友,可以参考一下.
reg.php
<?
session_start();
?>
<!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=gb2312" />
<title>56短信网实例(http://www.56dxw.com)</title>
<?
$action=$_GET["action"];
if ($action=='add')
{
$Code=trim($_POST["t_num"]);
// print($Code);
if($Code==$_SESSION["code"])
print( "<script>alert('通证成功')</script>");
else
print( "<script>alert('未通证成功')</script>");
unset($_SESSION['code']);
}
?>
<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.php",
type: "Post",
data: "Tel=" + $("#t_tel").val(),
success: function(msg) {
alert(msg);
}
})
}
</script>
</head>
<body>
<label>
<form id="form1" name="form1" method="post" action="reg.php?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> </p>
</body>
</html>
reg.php
<?php
session_start();
error_reporting(0);
header("content-type:text ml;charset=gb2312");
//帐号配置文件
$comid= "60"; //企业ID
$username= "test1"; //用户名
$userpwd= "qwqwqw"; //密码
$smsnumber= "1061"; //所用平台
function rstr($str){
if($str==1)
$error='代表发送成功';
else{
switch($str){
case -1:$error='手机号码不正确';break;
case -2:$error='除时间外,所有参数不能为空';break;
case -3:$error='用户名密码不正确';break;
case -4:$error='平台不存在';break;
case -5:$error='客户短信数量为0';break;
case -6:$error='客户账户余额小于要发送的条数';break;
case -8:$error='非法短信内容';break;
case -9:$error='未知系统故障';break;
case -10:$error='网络性错误';break;
default:$error='未知的错误';
}
}
print($error);
exit();
}
//调用56短信网的短信接口,网址:http://www.56dxw.com
function sendnote($mobtel,$msg){
global $username,$userpwd,$smsnumber,$comid;
$url = "http://jiekou.56dxw.com/sms/HttpInterface.aspx?comid=$comid&username=$username&userpwd=$userpwd&handtel=$mobtel&sendcontent=$msg