Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The realization method of the function of dream-weaving short message verification code

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The realization method of dream-weaving short message verification code function? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

How to realize the function of dream-weaving SMS verification code?

Now most websites need to use SMS CAPTCHA, because there is no SMS CAPTCHA plug-in, so several SMS CAPTCHA plug-ins have been written, one using Aliyun's SMS CAPTCHA interface, one using Ali greater than SMS CAPTCHA interface, one using Ali communication SMS CAPTCHA interface, and the other using Yunzhixun SMS verification code interface.

Contains 2 dream-weaving SMS verification code interfaces.

Dream weaving member SMS registration needs to be modified:

1. You need to create a table to record the CAPTCHA to prevent it from being sent multiple times. Here you have created a phonecode table.

2. Member/templets/reg-new.htm (register template to add elements)

3. Member/templets/js/reg_new.js (verify the mobile phone number)

4. Member/index_do.php (judge whether to send registration verification code according to backend settings)

5. Member/reg_new.php (verification, recording)

a. Use the Aliyun SMS API to access:

You need to insert the Aliyun SMS API code in the corresponding location of member/index_do.php. In particular, it is important to note that the official demo document of Ali Yun SMS is written by God, so ordinary people will report namespace errors when using it, which requires their own attention. In addition, you need to update the SMS template. Now Ali SMS template audit is very strict, no other variables are allowed, and there was no such problem before. Therefore, when the audit fails, you need to reduce the number of variables. (at present, the Aliyun SMS interface cannot be activated. The newly opened Ali communication interface cannot be used. It is only suitable for people who have been using Aliyun SMS messages for a long time.)

Function getrandchar ($length) {$str = null; $strPol = "0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen ($strPol)-1; for ("signature"); / * signature name * / $request- > setTemplateCode ("SMS_1111"); / * template code*/ $request- > setRecNum ($phone); / * destination mobile phone number * / $request- > setParamString ("{\" code\ ":\" $code\ ",\" tel\ ":\" phone number\ ") / * template variable, please ensure that the number is consistent with the audited SMS template variable. The number must be converted to a string * / 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 ('sent successfully, please check!' ,'- 1'); exit ();} exit ()

Attached is Aliyun SMS template: CAPTCHA: ${code}. You are registering. If you do not operate it yourself, please ignore this message. If you have any questions, please contact us! Tel: ${tel}

b. Use Ali Dayu's SMS interface to access:

Similarly, you need to insert the following code in the corresponding location of the member/index_do.php.

Function getrandchar ($length) {$str = null;//$strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; $strPol = "0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen ($strPol)-1 for ($iS0 / strPol / iappkey = '1111'; / / logging in to Ali is greater than viewing appkey. $client-> secretKey = 'aaaaaaaaaaaaaa'; / / logging in to Ali is greater than viewing secret. $req = new AlibabaAliqinFcSmsNumSendRequest;$req-> setExtend (""); $req-> setSmsType ("normal"); $req-> setSmsFreeSignName ("city dwelling"); / * signature name * / $req-> setSmsParam ("{\" code\ ":\" $code\ ",\" name\ ":\" Registration\ "); / * template variable, make sure it is consistent with the audited SMS template variable, and the number must be converted to a string * / $req-> setRecNum ($phone). / * Target phone number * / $req-> setSmsTemplateCode ("SMS_1111111"); / / Log in to Ali to view / * template ID number * / $resp = $client-> execute ($req); $inquery = "INSERT INTO `phonecode` (`ip`, `phone`, `phonecode`, `used`, `sendtime`) VALUES ('$ip','$to','$code','1','$nowtime')"; $rs = $dsql- > ExecuteNoneQuery2 ($inquery); if ($rs = 1) {ShowMsg ('send successfully, please check!' ,'- 1'); exit ();} exit ()

c. Use the latest Ali SMS interface to access:

Function getrandchar ($length) {$str = null;//$strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; $strPol = "0123456789"; $max = strlen ($strPol)-1 political for ($phone); / / required-SMS signature $request- > setSignName ("99 Shop Network"); / / required-SMS template Code$request- > setTemplateCode ("SMS_74725029"); / / optional-required (JSON format) $request- > setTemplateParam ("{\" number\ ":\" $number\ "}") / / optional-send SMS message serial number $request- > setOutId ("1234"); / / initiate an access request $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 "sent successfully, please check!" ; exit ();} exit ()

At this point, the three SMS interfaces of the Ali system are all here, and the corresponding SDK needs to be found and downloaded in Ariyun.

d. Use the Cloud message SMS interface to access:

Similarly, you need to insert the SMS interface code of Cloud News in the corresponding location of member/index_do.php.

Function getrandchar ($length) {$str = null;$strPol = "0123456789abcdefghijklmnopqrstuvwxyz"; $max = strlen ($strPol)-1 position for ($itemplateSMS ($appId,$to,$templateId,$param); $inquery = "INSERT INTO `phonecode` (`ip`, `phone`, `phonecode`, `used`, `sendtime`) VALUES ('$ip','$to','$code','1','$nowtime')"; $rs = $dsql- > ExecuteNoneQuery2 ($inquery); if ($rs = 1) {ShowMsg ('send successfully, please check!' ,'- 1'); exit ();} exit (); Thank you for reading! After reading the above, do you have a general understanding of the realization of the function of Weaving Dream SMS CAPTCHA? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report