Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

weflex/send-sms.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

16 Commits

Repository files navigation

send-sms.js

NPM version Build status Dependency Status Downloads

The library to send simple message which is compatible with multi-services, currently it supports the following services:

Installation

$ npm install send-sms --save

This library also is able to run at browser-side or any JavaScript environment.

Usage

const {
 SMS,
 adapters
} = require('send-sms');
const smsbao = new adapters.SMSBao({
 user: 'your user from smsbao',
 pass: 'your pass from smsbao'
});
const sms = new SMS('weflex', smsbao);
// when you need to send a simple message
sms.send('your phone number to send', 'foobar text');
// sms.send returns a Promise so if you are in ES7 environment
try {
 await sms.send(phone, text);
} catch (err) {
 console.error(err);
}

The above example will send a message to user like the following:

【weflex】foobar text

Write your adapter for service that you are using

const { Adapter } = require('send-sms');
class YourServiceAdapter extends Adapter {
 constructor(arguments) {
 super('your name', {
 // options like credentials
 });
 }
 request(phone, content) {
 // must implement this method in your self adapter, which does
 // send requests to service endpoint, and must return a Promise
 }
}

To see an example, see 短信宝

License

MIT @ WeFlex, Inc.

About

The library to send simple message which is compatible with multi-services like: 短信宝 and 容联云

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle によって変換されたページ (->オリジナル) /