Giter VIP home page Giter VIP logo

node-toptbsdk's Introduction

node-toptbsdk

为了更好的使用ES6/7开发,对淘宝官方Node.js版的topsdk进行修改,使用方法和官方一致,不同的是返回Promise结果。淘宝官方的sdk中使用urllib作为Http工具,这里修改为使用request

安装

npm install node-toptbsdk --save

使用方法

Promise

const TopClient = require('node-toptbsdk');

const client = new TopClient({
  appkey: 'appkey',
  appsecret: 'appsecret',
});

await client.execute('alibaba.aliqin.fc.sms.num.send', {
  extend: '123456',
  sms_type: 'normal',
  sms_free_sign_name: '阿里大于',
  rec_num: '12345678912',
  sms_template_code: 'SMS_8985285',
  sms_param: {
    customer: 'Ray'
  }
})

Async / await

const TopClient = require('node-toptbsdk');

async function sendSms() {
  const client = new TopClient({
    appkey: 'appkey',
    appsecret: 'appsecret',
    REST_URL: 'https://eco.taobao.com/router/rest'
  });

  let result;
  try {
    result = await client.execute('alibaba.aliqin.fc.sms.num.send', {
      extend: '123456',
      sms_type: 'normal',
      sms_free_sign_name: 'alibb',
      rec_num: '12345678912',
      sms_template_code: 'SMS_8985285',
      sms_param: {
        customer: 'Ray'
      }
    });
  } catch (err) {
    console.error(err);
  }

  console.log(result);
}

注意

默认是POST,如果使用GET等,execute的第三个参数请输入,如:

...
client.execute('alibaba.aliqin.fc.sms.num.send', {
  extend: '123456',
  ...
}, 'GET')
...

License

MIT

node-toptbsdk's People

Contributors

messilimeng avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.