bzoj 4198 [noI2015] Homer epic

2023-01-23   ES  

When implementing the verification of user registration and modification passwords, the function of sending mobile phone verification codes is often used. Here, it is mainly based on the TP5 framework to develop and organize the two platforms of Yunzhun and Alibaba Cloud SMS.

mainly introduced in three parts, 1. Cloud fast back; 2. Alibaba cloud back end; 3. front -end calls.

1. Cloud News SMS

official website:http://www.ucpaas.comDevelopment manual: demo:

TP5 framework development: 1. Download the Yunzhun SDK package; 2. Introduce SDK packages in Think of the TP5 framework; 3. In control:

4. Write the sending method in the controller:

5. The front -end click event call method (detailed ideas and code behind the blog post).

2, Alibaba Cloud SMS

background, controller specific operation reference   

1. Download the Alibaba Cloud SDK package, copy the API_ADK to the TP5 Extend directory, and rename it according to your own needs.

2. In your project application public (function) file comon.php head adds

3. Write the encapsulated function into the common.php

  * @param $ To to receiver 
  * @param $ Model SMS ID 
  * @param $ code SMS verification code 
  * @Return json 
 function send_sms ($ to, $ model, $ code) 
     Require_once '../extEnd/alisms/vendor/autoload.php'; 
     Config :: load (); // Load the area node configuration 
     $ config = db :: name ('SMS_CONFIG')-> Select (); 
     $ Accesskeyid = 'Corresponding to my background data'; 
     $ AccessKeysecret = 'Corresponding to your background data'; 
     $ templateparam = $ code; 
     // SMS ID ID 
     Switch ($ Model) { 
         Case 1: 
             $ TemplateCode = $ config [0] ['SMS_STENCIL_CODE']; // 
         Case 2: 
             $ TemplateCode = $ config [1] ['SMS_STENCIL_CODE']; // Reset the password SMS verification code template 
     // SMS API product name (SMS product name is fixed, no need to modify) 
     $ Product = "Dysmsapi"; 
     // SMS API product domain name (the interface address is fixed, no modification is required) 
     $ domain = ""; 
     // Temporarily do not support multi-region (currently only supports CN-HANGZHOU, please do not modify) 
     $ Region = "cn-Hanzhou"; 
     // Initialize user PROFILE instance 
     $ Profile = DEFAULTPROFILE :: GetProfile ($ Region, $ AccessKeyid, $ AccessKeySecret); 
     // Increase service nodes 
     DefaultProfile :: adDEndpoint ("cn-Hangzhou", "cn-Hanzhou", $ Product, $ Domain); 
     // Initialize ACSCLIENT for initiating requests 
     $ avclient = new defaultAclient ($ Profile); 
     // Initialize the SENDSMSREQUSST instance to set the parameters of sending text messages 
     $ Request = New SendsmsRquest (); 
     // Must be filled, set a SMS receiving number 
     $ Request-> Setphonenumbers ($ To); 
     // Must be filled, set the signature name 
     $ Request-> Setsignname ('x net'); 
     // Must -fill, set the template code 
     $ Request-> SettemplateCode ($ TemplateCode); 
     // Optional, set the template parameter 
     if ($ templateparam) { 
         $ Request-> SettemplateParam (JSON_ENCODE ($ TemplateParam)); 
     // Initize access requests 
     $ avponse = $ avclient-> GetacsResponse ($ Request); 
     // Return to the request result 
     $ result = json_decode (json_encode ($ acsresponse), true); 
     // For the specific return value reference document: https: // SPM = A2C4G.11186623.563.yse8fk 
     Return $ result; 

4. Cost in the controller, the parameters are: mobile phone number, SMS template, verification code

  three, front -end call


Related Posts

Oracle dynamic monitoring and static monitoring differences

AWS-EC2 use the command line to find the area and available area

[iOS Baidu Map Series 2] Satellite maps, traffic maps, heat maps, and add coverage on basic maps

Android compilation system Makefile ( writing

bzoj 4198 [noI2015] Homer epic

Random Posts

ubuntu16.04+vscode+opencv3.1- Read the picture Jen

CPINTDC and CClientdc Alanchen

basic mrproto

ORA-01078: Failure in Processing System Parameters problem (Oracle 11G)

Sorting Algorithm-Base Sorting-Detailed Explanation and Code Analysis