美文网首页
学习笔记-0818-阿里大于短信验证

学习笔记-0818-阿里大于短信验证

作者: 幽谷听泉 | 来源:发表于2016-08-19 09:28 被阅读0次

    alidayu短信验证码

    官网下载nodejs版本的SDK或者直接在npgjs.com上搜索alidayu包,

     npm install super-alidayu --save 
    

    使用方式:

    'use strict';
    const AliDaYu = require('super-alidayu');
    
    var= client = new AliDaYu({
        app_key: 'xxxxxxx',
        secret: 'xxxxxxxx',
    });
    
    var options = {
        sms_free_sign_name: '登录验证',
        sms_param: {
          code: '1234',
          product: '一登',
       },
       rec_num: '13800138000',  //收信手机号
       sms_template_code: 'SMS_4045620',
    };
    
    // 发送短信,promise方式调用 
    client.sms(options)
      .then(ret => console.log('success', ret))
      .catch(err => console.log('error', err));
    
    // 发送短信,callback方式调用 
    client.sms(options, (err, ret) => {
      if (err) {
        console.log('error', err);
      } else {
        console.log('success', ret);
      }
    });
    

    在应用中修改app_key/secret/code

    code   //用户收到的验证码
    app_key  //alidayu提供的应用的key如下图
    secret   //alidayu提供的app secret 如下图
    
    Paste_Image.png

    Ajax学习

    相关文章

      网友评论

          本文标题:学习笔记-0818-阿里大于短信验证

          本文链接:https://www.haomeiwen.com/subject/menvsttx.html