使用的短信商是:容联云通讯 网址:http://www.yuntongxun.com/
代码均亲测,可以直接使用。
1.制作步骤:
打开 /e/template/member/register.php进行修改
先把用户名,三个汉字,改成手机号
在邮箱的表单下面,多增加一个验证码的表单
*
function get_code(){ var phe=document.userinfoform.username.value; if(document.userinfoform.username.value == "") { alert("手机号不能为空"); document.userinfoform.username.focus(); return false; } $.ajax({ type: "POST", url: "/e/extend/phone/index.php", dataType: 'html', data:{ phe:phe, }, success:function(data,status){ alert("发送成功"); return false; }, error:function(){ alert("发送验证码不成功,请重试"); return false; } }) }
2.将手机短信验证代码放入e/extend/文件下
将SDK文件代码需要做部分修改:
/*
* Copyright (c) 2014 The CCP project authors. All Rights Reserved.
*
* Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
* that can be found in the LICENSE file in the root of the web site.
*
* http://www.yuntongxun.com
*
* An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
accountToken = ”【云通讯–应用管理中–AUTH TOKEN:xx的值】
serverIP=’app.cloopen.com’;
softVersion=’2013-12-26’;
class REST {
private
AccountToken;
private
ServerIP;
private
SoftVersion;
private
BodyType = “xml”;//包体格式,可填值:json 、xml
private
Filename=”./log.txt”; //日志文件
private
ServerIP,
SoftVersion)
{
this->ServerIP =
this->ServerPort =
this->SoftVersion =
this->Handle = fopen($this->Filename, ‘a’);
}
/**
* 设置主帐号
*
* @param AccountSid 主帐号
* @param AccountToken 主帐号Token
*/
function setAccount(
AccountToken){
AccountSid;
AccountToken;
}
/**
* 设置应用ID
*
* @param AppId 应用ID
*/
function setAppId(
this->AppId = $AppId;
}
/**
* 打印日志
*
* @param log 日志内容
*/
function showlog(
this->enabeLog){
fwrite(
log.”\n”);
}
}
/**
* 发起HTTPS请求
*/
function curl_post($url,$data,$header,$post=1)
{
//初始化curl
$ch = curl_init();
//参数设置
$res= curl_setopt ($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, $post);
if($post)
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
$result = curl_exec ($ch);
//连接失败
if($result == FALSE){
if($this->BodyType=='json'){
$result = "{\"statusCode\":\"172001\",\"statusMsg\":\"网络错误\"}";
} else {
$result = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Response><statusCode>172001</statusCode><statusMsg>网络错误</statusMsg></Response>";
}
}
curl_close($ch);
return $result;
}
/**
* 发送模板短信
* @param to 短信接收彿手机号码集合,用英文逗号分开
* @param datas 内容数据
* @param
to,
tempId)
{
//主帐号鉴权信息验证,对必选参数进行判空。
this->accAuth();
if(
this->BodyType==”json”){
i=0;$i