npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yunpian-sdk

v1.0.0

Published

Yunpian(云片API)Node.js SDK

Downloads

15

Readme

YunPian SDK For Node.js

npm npm npm

云片注册地址: https://www.yunpian.com/component/reg?inviteCode=atevkh

Minimum, Flexible, Scalable.

支持Lazy Require。

Table of Contents generated with DocToc

安装和使用

国际惯例:

npm install yunpian-sdk --save

公共参数:

var options = {
  apikey: 'xxxxxxx'
};

ES7:

import {USER} from 'yunpian-sdk';
const user = new USER({
  apikey: 'xxxx'
});
// Within Async Func
(async() => {
  const result = await user.set({
    emergency_contact: 'Willin',
    emergency_mobile: '1xxxxxxxxxx'
  });
  // xxxx
});

ES5:

var YUNPIAN = require('yunpian-sdk');
// 加载全部方法
var user = new YUNPIAN.USER({
  apikey: 'xxxx'
});
// 或加载某些方法
var user = new YUNPIAN.USER({
  apikey: 'xxxx'
}, ['get', 'set']);
// 或加载某个方法
var user = new YUNPIAN.USER({
  apikey: 'xxxx'
}, 'get');
user.set({
  emergency_contact: 'Willin',
  emergency_mobile: '1xxxxxxxxxx'
}).then(function(result){
  // xxxx
});

手机号合法性校验

ES7 示例代码:

import {phone} from 'yunpian-sdk';

// 加区号匹配国际各国号码格式
phone('+8613312345678'); // true
phone('+85265698900'); // true
phone('+112345678'); // false

// 不加区号按中国号码匹配
phone('13312341234'); // true
phone('112345678'); // false

// 按地区匹配
// 地区码使用3位缩写国家代码(大写)
phone('+18175698900', 'USA'); // true
phone('13212345678', 'CHN'); // true
phone('+18175698900', 'CHN'); // false
phone('13212345678', 'HKG'); // false

ES5 示例代码:

var phone = require('yunpian-sdk').phone;

phone('+8613312345678'); // true
phone('13312341234'); // true
phone('13212345678', 'CHN'); // true

已支持的接口

USER - 账户API

API文档参考: https://www.yunpian.com/api2.0/user.html

ES7 示例:

import {USER} from 'yunpian-sdk';

const user = new USER({
  apikey: 'xxxx'
});

(async() => {
  const user = await user.get();
  // xxxx

  const result = await user.set({
    emergency_contact: 'Willin',
    emergency_mobile: '1xxxxxxxxxx'
  });
  // xxxx
})();

TPL - 模板API

API文档参考: https://www.yunpian.com/api2.0/tpl.html

SMS - 短信API

API文档参考: https://www.yunpian.com/api2.0/sms.html

ES7 示例:

import {SMS} from 'yunpian-sdk';

const sms = new SMS({
  apikey: 'xxxx'
});

(async() => {
  console.log(await sms.singleSend({
    mobile: 'xxxx',
    text: '【xxxx】您的验证码是:123456 (验证码10分钟内有效),请勿将验证码泄露给其他人。如非本人操作,请忽略本短信。'
  }));
})();

VOICE - 语音API

API文档参考: https://www.yunpian.com/api2.0/voice.html

FLOW - 流量API

API文档参考: https://www.yunpian.com/api2.0/flow.html

License

MIT

通过支付宝捐赠:

qr