• 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>
    

      

      

      

      

  • 相关阅读:
    react脚手架搭建及配置
    mac使用技巧
    nginx配置
    vue常见前端UI库
    自定义指令
    代码缩进修改
    webpack学习入门
    webpack使用extract-text-webpack-plugin打包时提示错误
    webpack未成功全局安装
    基于jQuery的AJAX实现三级联动菜单
  • 原文地址:https://www.cnblogs.com/potato-lee/p/6266830.html
Copyright © 2020-2023  润新知