How to implement the SMS verification code function of Dreamweaver
How to implement the Dreamweaver SMS verification code function?
Most websites now require SMS verification codes. Because DreamWeaver officially does not have an SMS verification code plug-in, we wrote several SMS verification code plug-ins. One of them uses Alibaba Cloud's SMS verification code. Interfaces, one uses Alibaba's SMS verification code interface, one uses Alibaba Communications' SMS verification code interface, and the other uses Yunzhixun's SMS interface.
Recommended learning: DreamWeaver cms
The following tutorial contains 2 Dreamweaver SMS verification code interfaces.
Things that need to be modified in the SMS registration of Dreamweaver members:
1. It is necessary to create a table to record the verification code to prevent multiple sending. Here, a phonecode table is created.
2. member/templets/reg-new.htm (Add elements to registration template)
3. member/templets/js/reg_new.js (Verify mobile phone number)
4. member/index_do.php (Determine whether to send the registration verification code according to the background settings)
5. member/reg_new.php (verification, record)
a. Use Alibaba Cloud SMS Interface access:
You need to insert the Alibaba Cloud SMS interface code at the corresponding location of member/index_do.php. It is particularly important to note that the official demo document of Alibaba Cloud SMS is written by a master, so ordinary people will report namespace errors when using it. This needs to be paid attention to. In addition, the SMS template needs to be updated. Now Alibaba SMS template review is very strict and other variables are not allowed. This problem did not exist before. Therefore, when the audit fails, variables need to be reduced. (Currently it is no longer possible to open the Alibaba Cloud SMS interface. The newly opened Alibaba Cloud SMS interface cannot use this code. It is only suitable for those who have opened Alibaba Cloud SMS a long time ago)
function getrandchar($length){ $str = null; $strPol = "0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen($strPol)-1; for($i=0;$i<$length;$i++){ $str.=$strPol[rand(0,$max)]; } return $str; } $code = getrandchar(5); require_once(DEDEINC.'/aliyun-php-sdk-core/Config.php'); use Sms\Request\V20160927 as Sms; $iClientProfile = DefaultProfile::getProfile("cn-shenzhen", "your accessKey", "your accessSecret"); //登录阿里云查看: "your accessKey", "your accessSecret" $client = new DefaultAcsClient($iClientProfile); $request = new Sms\SingleSendSmsRequest(); $request->setSignName("签名");/*签名名称*/ $request->setTemplateCode("SMS_1111");/*模板code*/ $request->setRecNum($phone);/*目标手机号*/ $request->setParamString("{\"code\":\"$code\",\"tel\":\"电话号码\"}");/*模板变量,请确保跟审核过的短信模版变量一致,数字一定要转换为字符串*/ try { $response = $client->getAcsResponse($request); print_r($response); } catch (ClientException $e) { print_r($e->getErrorCode()); print_r($e->getErrorMessage()); } catch (ServerException $e) { print_r($e->getErrorCode()); print_r($e->getErrorMessage()); } $inquery = " INSERT INTO `dede_phonecode` (`ip`,`phone`,`phonecode`,`used`,`sendtime`) VALUES ( '$ip','$to','$code','1','$nowtime'); "; $rs = $dsql->ExecuteNoneQuery2($inquery); if( $rs = 1 ){ ShowMsg('发送成功,请注意查收!','-1'); exit(); } exit();
Attached is the Alibaba Cloud SMS template : Verification code: ${code}. You are registering. If it is not done by you, please ignore this message. If you have any questions, please contact us! Telephone: ${tel}
b. Use Alibaba Dayu’s SMS interface to access:
The same needs to be in the corresponding location of member/index_do.php Insert the following code.
function getrandchar($length){ $str = null; //$strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; $strPol = "0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen($strPol)-1; for($i=0;$i<$length;$i++){ $str.=$strPol[rand(0,$max)]; } return $str; } $code = getrandchar(5); require_once(DEDEINC.'/alidayu-php-sdk/TopSdk.php'); $client = new TopClient; $client ->appkey = '111111' ; //登录阿里大于查看appkey。 $client ->secretKey = 'aaaaaaaaaaaaaa' ; //登录阿里大于查看secret。 $req = new AlibabaAliqinFcSmsNumSendRequest; $req ->setExtend( "" ); $req ->setSmsType( "normal" ); $req ->setSmsFreeSignName( "城子居" ); /*签名名称*/ $req ->setSmsParam( "{\"code\":\"$code\",\"name\":\"注册\"}" ); /*模板变量,请确保跟审核过的短信模版变量一致,数字一定要转换为字符串*/ $req ->setRecNum($phone);/*目标手机号*/ $req ->setSmsTemplateCode( "SMS_1111111" );//登录阿里大于查看/*模板ID编号*/ $resp = $client ->execute( $req ); $inquery = " INSERT INTO `imm_phonecode` (`ip`,`phone`,`phonecode`,`used`,`sendtime`) VALUES ( '$ip','$to','$code','1','$nowtime'); "; $rs = $dsql->ExecuteNoneQuery2($inquery); if( $rs = 1 ){ ShowMsg('发送成功,请注意查收!','-1'); exit(); } exit();
c. Use the latest Alibaba Communication SMS interface to access:
function getrandchar($length){ $str = null; //$strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; $strPol = "0123456789"; $max = strlen($strPol)-1; for($i=0;$i<$length;$i++){ $str.=$strPol[rand(0,$max)]; } return $str; } $number = getrandchar(4); require_once(DEDEINC.'/aliyun-php-sdk-core/Config.php'); require_once(DEDEINC.'/Dysmsapi/Request/V20170525/SendSmsRequest.php'); require_once(DEDEINC.'/Dysmsapi/Request/V20170525/QuerySendDetailsRequest.php'); function sendSms() { global $phone, $number; //此处需要替换成自己的AK信息 $accessKeyId = "yourAccessKeyId"; $accessKeySecret = "yourAccessKeySecret"; //短信API产品名 $product = "Dysmsapi"; //短信API产品域名 $domain = "dysmsapi.aliyuncs.com"; //暂时不支持多Region $region = "cn-beijing"; //初始化访问的acsCleint $profile = DefaultProfile::getProfile($region, $accessKeyId, $accessKeySecret); DefaultProfile::addEndpoint("cn-beijing", "cn-beijing", $product, $domain); $acsClient= new DefaultAcsClient($profile); $request = new Dysmsapi\Request\V20170525\SendSmsRequest; //必填-短信接收号码 $request->setPhoneNumbers($phone); //必填-短信签名 $request->setSignName("99商铺网"); //必填-短信模板Code $request->setTemplateCode("SMS_74725029"); //选填-假如模板中存在变量需要替换则为必填(JSON格式) $request->setTemplateParam("{\"number\":\"$number\"}"); //选填-发送短信流水号 $request->setOutId("1234"); //发起访问请求 $acsResponse = $acsClient->getAcsResponse($request); } sendSms(); $inquery = " INSERT INTO `imm_phonecode` (`ip`,`phone`,`phonecode`,`used`,`sendtime`) VALUES ( '$ip','$phone','$number','1','$nowtime'); "; $rs = $dsql->ExecuteNoneQuery2($inquery); if( $rs = 1 ){ echo "发送成功,请注意查收!"; exit(); } exit();
Here are all the three SMS interfaces of Alibaba. The corresponding SDK needs to be found in the official Alibaba Cloud download.
d. Use Yunzhixun SMS interface to access:
Similarly, you need to insert the Yunzhixun SMS interface code in the corresponding position of member/index_do.php.
function getrandchar($length){ $str = null; $strPol = "0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen($strPol)-1; for($i=0;$i<$length;$i++){ $str.=$strPol[rand(0,$max)]; } return $str; } require_once(DEDEINC.'/ucpaas.class.php'); $options['accountsid']=''; //对应ucpaas.com用户ID $options['token']=''; //对应ucpaas.com里面的用户token $ucpass = new Ucpaas($options); $appId = ""; //对应ucpaas.com里面的项目ID $to = $phone; $templateId = ""; //对应ucpaas.com里面的短信模版ID $code = getrandchar(5); $param= $code.',短信模版参数2'.',短信模版参数3'; // $code为生成的验证码,短信模版参数2,短信模版参数3,参数之间用英文逗号间隔。 $ucpass->templateSMS($appId,$to,$templateId,$param); $inquery = " INSERT INTO `dede_phonecode` (`ip`,`phone`,`phonecode`,`used`,`sendtime`) VALUES ( '$ip','$to','$code','1','$nowtime'); "; $rs = $dsql->ExecuteNoneQuery2($inquery); if( $rs = 1 ){ ShowMsg('发送成功,请注意查收!','-1'); exit(); } exit();
Similarly attach the SMS template: Verification code: {1}. You are at {2}. If you are not responsible for this, please ignore this message. If you have any questions, please contact us! Tel: {3}
The above is the detailed content of How to implement the SMS verification code function of Dreamweaver. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to import css into DreamWeaver: 1. Place the HTML template file in the "templets" folder; 2. Change the suffix of the HTML file to ".htm"; 3. Add "{dede:" in front of the original style path: global.cfg_templets_skin/}" can be used.

It is a common situation to encounter problems when installing Dreamweaver. One of the possible problems is that php7.0 cannot be successfully installed. In this article, we will explain how to solve this problem.

Dreamweaver is a very famous CMS. It is used by many websites due to its simplicity and ease of use. Its backend is developed using PHP, and the latest official version is Dreamweaver PHP 5.7. In this article, we will explore the new features and advantages of DreamWeaver PHP 5.7 version.

The database is the core of website operation and stores important information such as user data and article content. Therefore, the backup and recovery of database files is particularly important during website operation. For websites built using Dreamweaver CMS, the recovery of database files is also a critical task. This article will introduce in detail the recovery method of Dreamweaver CMS database files, and provide specific code examples to help users quickly restore website data and ensure the normal operation of the website. 1. Back up the database file. Before restoring the database file, you first need to ensure that it has been

DreamWeaver is a very popular website construction system, and its architecture is based on the PHP language. Therefore, Dreamweaver requires PHP to run. So, specifically, how many PHPs are needed to weave dreams? This is not a simple question. This article will introduce the PHP version and number of components required for Dreamweaver from the following aspects.

cms is not Dreamweaver, cms refers to content management system, and Dreamweaver is just a kind of cms; Dreamweaver cms refers to Dreamweaver content management system, and content management system is a kind of WEB front-end and back-end office system or process. A software system between websites; cms has many excellent designs based on templates, which can speed up website development and reduce development costs.

Dreamweaver CMS is an open source content management system developed based on PHP5 and is widely used in the field of website construction. It is very important for developers to master the key points of Dreamweaver PHP5. This article will introduce some key points and provide specific code examples to help readers better understand and apply DreamWeaver PHP5. 1. Files included in the development of DreamWeaver CMS often require data sharing and code reuse between different files. PHP's file inclusion feature is an effective way to solve this problem. In DreamWeaver CMS, often

Dreamweaver requires PHP version 5.2 and above. The installation method: 1. First install PHP and configure the environment; 2. Download the DedeCMS installation package and extract it to the root directory of the website; 3. Open the website URL and follow the prompts to complete the installation; 4. After the installation is complete, you can access the Dreamweaver backend through http://localhost/yourwebsite.
