New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-taobao-topclient

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-taobao-topclient

taobao topsdk for node.js(support es6/7,promise,async/await)

latest
Source
npmnpm
Version
0.1.7
Version published
Weekly downloads
822
-28.52%
Maintainers
1
Weekly downloads
 
Created
Source

node-taobao-topclient

npm version

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

安装

npm install node-taobao-topclient --save

使用方法

Promise

import TopClient from 'node-taobao-topclient';

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

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'
  }
})
.then((result) => {
  console.log(result);
})
.catch((err) => {
  console.error(err);
});

Async / await

import TopClient from 'node-taobao-topclient';

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: '阿里大于',
      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

Keywords

taobao

FAQs

Package last updated on 18 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts