Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.
/ swisscom-sms-api Public archive

Node module to send SMS via the Swisscom SMS API

Notifications You must be signed in to change notification settings

katunch/swisscom-sms-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NOTE: This repo is no longer maintained...

swisscom-sms-api

Node module to send SMS via the Swisscom SMS API.

Swisscom Developer Account

  1. Register on the Swisscom Developer Portal.
  2. Generate your API key here.

Usage (CoffeeScript)

#
# example.coffee
#

SMSApi 		= require 'swisscom-sms-api'

config = 
	smsApi:
		sender: '+41791234567'
		clientId: 'YOUR-CONSUMER-KEY-HERE'

sms = 
	recipient: '+41791234567'
	messageText: 'hello world'

gateway = new SMSApi config.smsApi

gateway.on 'sent', ()->
	console.log 'all messages sent'

gateway.on 'error', (error) ->
	console.log 'an error occurred: ', error

gateway.on 'deliveryStatus', (status) ->
	consoloe log 'this is a status for each recipient', status

gateway.send sms.recipient, sms.messageText

Run coffee example.coffee from your command line.

Usage (Javascript)

//
// example.js
//
var SMSApi, config, gateway, sms;

SMSApi = require('swisscom-sms-api');

config = {
  smsApi: {
    sender: '+41791234567',
    clientId: 'YOUR-CONSUMER-KEY-HERE'
  }
};

sms = {
  recipient: '+41791234567',
  messageText: 'hello world'
};

gateway = new SMSApi(config.smsApi);

gateway.on('sent', function() {
  return console.log('all messages sent');
});

gateway.on('error', function(error) {
  return console.log('an error occurred: ', error);
});

gateway.on('deliveryStatus', function(status) {
  return console.log('deliveryStatus: ', status);
});

gateway.send(sms.recipient, sms.messageText);

Run node example.js from your command line.

#Delivery Status Please refer to the API Documentation. There are two known delivery status which the service returns:

  1. DeliveredToNetwork - means the sms is deliverd to the mobile network and will be delivered to the recipient as soon as possible.
  2. DeliveryImpossible - means the delivery to the mobile network is not possible. An unknown recipient number can be a reason.

Installation

npm install swisscom-sms-api

Debugging

The Swisscom SMS API uses debug for logging. Just set the DEBUG environment variable to swisscom-*

  • Example using CoffeeScript: DEBUG=swisscom-* coffee example.coffee
  • Example using Javascript: DEBUG=swisscom-* node example.js

Issues

About

Node module to send SMS via the Swisscom SMS API

Resources

Stars

Watchers

Forks

Packages

No packages published