帝国cms7.0手机注册验证

使用的短信商是:容联云通讯 网址: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.
*/
a c c o u n t S i d = A C C O U N T S I D x x x accountToken = ”【云通讯–应用管理中–AUTH TOKEN:xx的值】
a p p I d = A p p I D ( ) x x serverIP=’app.cloopen.com’;
s e r v e r P o r t = 8883 ; softVersion=’2013-12-26’;

class REST {
private A c c o u n t S i d ; p r i v a t e AccountToken;
private A p p I d ; p r i v a t e ServerIP;
private S e r v e r P o r t ; p r i v a t e SoftVersion;
private B a t c h ; / / p r i v a t e BodyType = “xml”;//包体格式,可填值:json 、xml
private e n a b e L o g = t r u e ; / / t r u e p r i v a t e Filename=”./log.txt”; //日志文件
private Handle;       function __construct( ServerIP, S e r v e r P o r t , SoftVersion)
{
t h i s > B a t c h = d a t e ( Y m d H i s ) ; this->ServerIP = S e r v e r I P ; this->ServerPort = S e r v e r P o r t ; this->SoftVersion = S o f t V e r s i o n ; this->Handle = fopen($this->Filename, ‘a’);
}

/**
* 设置主帐号
*
* @param AccountSid 主帐号
* @param AccountToken 主帐号Token
*/
function setAccount( A c c o u n t S i d , AccountToken){
t h i s > A c c o u n t S i d = AccountSid;
t h i s > A c c o u n t T o k e n = AccountToken;
}

/**
* 设置应用ID
*
* @param AppId 应用ID
*/
function setAppId( AppId){ this->AppId = $AppId;
}

/**
* 打印日志
*
* @param log 日志内容
*/
function showlog( log){        if( this->enabeLog){
fwrite( t h i s > H a n d l e , 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 t e m p I d I d / f u n c t i o n s e n d T e m p l a t e S M S ( to, d a t a s , tempId)
{
//主帐号鉴权信息验证,对必选参数进行判空。
a u t h = this->accAuth();
if( a u t h ! = ) r e t u r n $ a u t h ; / / i f ( this->BodyType==”json”){
d a t a = ; f o r ( i=0;$i

猜你喜欢

转载自blog.csdn.net/qq_42829670/article/details/82119515