美文网首页
node实现短信发送验证码(基于阿里大于)

node实现短信发送验证码(基于阿里大于)

作者: heachou | 来源:发表于2017-04-26 17:36 被阅读0次

    <pre>
    // 来自阿里大鱼的api接口
    TopClient = require('./node_modules/node-msg/topClient').TopClient;
    console.log(TopClient);
    var client = new TopClient({
    'appkey': 'xxxxxxxxxxx',
    'appsecret': 'xxxxxxxxxxxxxxxxx',
    'REST_URL': 'http://gw.api.taobao.com/router/rest'
    });
    // api 接口
    client.execute('alibaba.aliqin.fc.sms.num.send', {
    'extend': '',
    'sms_type': 'normal', //必填项
    'sms_free_sign_name': 'xxxx', //短信签名
    'sms_param': '{"number":"789012"}', //短信中需要传入的参数
    'rec_num': '1300000000', //接受短信的手机号
    'sms_template_code': "xxxxxx" //短信模板ID
    }, function(error, response) {
    if (!error) console.log(response);
    else console.log(error);
    });
    </pre>
    1.去阿里大于,下载node-sdk,我这里是解压到node_modules文件夹下了,并且将文件夹重命名为node-msg了,查看package.json,安装相关依赖。
    2.申请创建应用,拿到appkey等
    3.申请短信签名与短信模板等
    4.将相关信息填入上述代码中
    5.run

    相关文章

      网友评论

          本文标题:node实现短信发送验证码(基于阿里大于)

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