holla22 / clickatell-node

NodeJS library to interact with the Clickatell SMS Gateway

Home Page:http://www.cainsvault.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clickatell NodeJS Library

You can see our other libraries and more documentation at the Clickatell APIs and Libraries Project.


Master: Build Status

This library allows easy access to connecting the Clickatell's different messenging API's.

  1. Installation

This library is managed by the Node Package Manager

npm install clickatell-node

  1. Usage

All calls are asynchronous and the parameters follows the nodeJS convention of specifying any errors as the first parameter and the response as the second.

var clickatell = require('clickatell-node').http(user, pass, api_id);
// var clickatell = require('clickatell-node').rest(token);

clickatell.sendMessage(["00000000000"], "My Message", {}, function (err, messages) {

    for (var key in messages) {
        var message = messages[key];

        console.log(message);

        // Message response format:
        // message.id (false if error)
        // message.destination
        // message.error (false if no error)
        // message.code (false if no error)
    }

});
  1. Supported API calls

The available calls should be defined as the following. Whenever you write a new adapter (API type) you should also try to stick to this interface.

sendMessage(to, message, extra, callback);

getBalance(callback);

stopMessage(apiMsgId, callback);

queryMessage(apiMsgId, callback);

routeCoverage(msisdn, callback);

getMessageCharge(apiMsgId, callback);

The callback uses the standard way of handling response and will be invoked with the following parameters:

sendMessage(["0000000000"], "My Message", {}, function (err, messages) {

});
  1. SendMessage parameters that are not supported

The sendMessage calls supports a third parameter called extra. This parameter can be used to specify any values in the Clickatell documentation that the library does not support as part of the public interface.

  1. Testing

To run the library test suite just execute npm test from the library root. Please make sure all tests are passing before pushing back any changes.

About

NodeJS library to interact with the Clickatell SMS Gateway

http://www.cainsvault.com

License:MIT License


Languages

Language:JavaScript 100.0%