项目作者: nextsms

项目描述 :
JS Client for NextSMS
高级语言: TypeScript
项目地址: git://github.com/nextsms/js-client.git
创建时间: 2020-12-31T06:56:40Z
项目社区:https://github.com/nextsms/js-client

开源协议:MIT License

下载


NextSMS Client for Node.js

Tests


The NextSMS SDK allows developers to easily integrate NextSMS solutions in their Javascript code, and build robust applications and software.

Documentation

Take a look at the SDK docs here.

Usage

NOTE:
> Test Mode ONLY Single destination and Multiple destinations APIs support testing mode.

Quick Examples

  1. yarn add @nextsms/js-client
  2. # or
  3. npm i @nextsms/js-client
  1. import NextSMS from '@nextsms/js-client';
  2. // Populate the credentials
  3. const username = 'username';
  4. const password = 'password';
  5. const apiKey = null';
  6. // Initiate with credentials
  7. let nextsms = new NextSMS({ username, password, apiKey, environment: 'testing' });
  8. const data = {
  9. from: 'NEXTSMS',
  10. to: '255123456789',
  11. text: 'Hello World',
  12. };
  13. // Send the sms
  14. nextsms
  15. .singleDestination(data)
  16. .then(data => {
  17. // Print results
  18. console.log(data);
  19. })
  20. .catch(error => {
  21. console.log('error: ' + error);
  22. });

Using base64 api key

  1. import NextSMS from '@nextsms/js-client';
  2. // Populate the credentials
  3. const username = null;
  4. const password = null;
  5. const apiKey = 'yourBase64Key'; // this is generated on https://www.blitter.se/utils/basic-authentication-header-generator/ as mentioned on nextsms api documentation.
  6. // Initiate with credentials
  7. let nextsms = new NextSMS({ username, password, apiKey, environment: 'testing' });
  8. const data = {
  9. from: 'NEXTSMS',
  10. to: '255123456789',
  11. text: 'Hello World',
  12. };
  13. // Send the sms
  14. nextsms
  15. .singleDestination(data)
  16. .then(data => {
  17. // Print results
  18. console.log(data);
  19. })
  20. .catch(error => {
  21. console.log('error: ' + error);
  22. });

Testing

  1. yarn test

Opening Issues

If you have a feature request or you encounter a bug, please file an issue on our issue tracker on GitHub.

Credits

License

The MIT License (MIT). Please see License File for more information.