The library to send simple message which is compatible with multi-services, currently it supports the following services:
- ippanel (ippanel.com)
- twilio (www.yuntongxun.com)
$ npm install git+https://github.com/mobinco/send-sms.js.git --save
This library also is able to run at browser-side or any JavaScript environment.
const {
SMS,
adapters
} = require('send-sms');
const ippanel = new adapters.IPPanel({
apiKey: 'your api key'
});
const sms = new SMS(ippanel);
// when you need to send a simple message
sms.send('your phone number to send', 'foobar text', 'from tel line');
// sms.send returns a Promise so if you are in ES7 environment
try {
await sms.send(phone, text, from);
} catch (err) {
console.error(err);
}
The above example will send a message to user like the following:
foobar text
const { Adapter } = require('send-sms');
class YourServiceAdapter extends Adapter {
constructor(arguments) {
super({
// options like credentials
});
}
send(phone, content, from) {
// 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 (adapters/smsbao.js)
MIT @ Mobinco, Inc.