Nodejs 發送短信驗證碼


 1.需要安裝模塊 >npm install leanengine --save-dev

2.調用模塊 

const AV=require("leanengine");

3.配置短信用戶的賬號驗證

AV.initialize("GSegQ5DVhSmUW0qxsSFlnNa9-gzGzoHsz","gCvYugC6OXyMNBGvgIkHXKv4")

4.寫返回函數

//短信定制服務
    app.get("/sendMesa.do",function(req,res){
         console.log(req.query);
        let phoneNumber=req.query.phoneNumber;
        AV.Cloud.requestSmsCode({
            mobilePhoneNumber:phoneNumber,
            name:'傻豬豬',//應用名稱
            op:'傻豬豬注冊驗證',//某種操作
            tt1:1//分鍾計算的有效性
        }).then(function(data){
            console.log("發送成功!");
            res.send("succeed!")
        },function(err){
            console.log(err);
            res.send("failed!")
        })
    })

5.簡單的html界面為

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<form action="sendMesa.do">
    <input type="text" name="phoneNumber"/>
    <button>發送驗證碼</button>
</form>
</body>
</html>

  

  

  

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM