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>示例1</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> 以下短信接口,支持长短信,支持回复,可以应用于团购订单提醒,手机短信验证,会员通知,客户交流,速度挺不错的:参考网址:http:www.56dxw.com
<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>
sms.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&sendtime=&smsnumber=$smsnumber";
$string = file_get_contents($url);
return rstr($string);
}
$_SESSION["code"]="12365";
$handtel =$_POST["Tel"];
$msg="手机验证码是:".$_SESSION["code"];
!$handtel && die('手机号必填');
!$msg && die('发生内容必填');
echo sendnote($_POST["Tel"],urlencode($msg));
?>
来源:https://www.cnblogs.com/jjzydysl/archive/2012/02/22/2363384.html