Giter VIP home page Giter VIP logo

zamano-api's Introduction

zamano-api

Node.js API for Zamano, a mobile message aggregation service. Allows servers to send and recieve mobile text and binary messages.

Version: 0.1.5

Setup

To install the package, run:

npm install zamano-api

Then call require with your client ID and password provided by Zamano. The id and password are required by zamano to authenticate you before sending your mobile message.

var zamano = require('zamano-api')('CLIENT_ID', 'ZAMANO_PASSWORD')

Usage

Zamano has API methods for both sending and receiving mobile messages.

zamano.sendMessage(opts, callback)

zamano.sendMessage sends a text message to a mobile number over a specific mobile network operator. This method calls back with either a success object or error object with messages from Zamano's service. Internally, this method sends a request to Zamano's HTTP API and parses the XML response into a JavaScript object.

zamano.sendMessage({
  sourceMsisdn:      'SHORT_CODE',
  destinationMsisdn: 'PHONE_NUMBER',
  messageText:       'Hello world',
  operatorId:        'ID_NUMBER'
}, function(err, out) {...})

Parameters:

  • opts (Object)

    • destinationMsisdn - destination mobile phone number.
    • messageText - text of the message.
    • sourceMsisdn (optional) - short code representing the tariff amount and country.
    • operatorId (optional) - The unique identifier of the Mobile Network Operator.
    • requestId (optional) - a reference/tag for this message.
    • sourceMsisdnTag (optional) - the label that the message will appear to come from on end users' handsets.
    • clientId (optional) - an override for the Id set at initialization.
    • password (optional) - an override for the password set at initialization.
  • callback (Function) - a function with conventional node.js function(err, out) signature. If the message was a success, the out object will have a responseId tracking number generated by zamano's server.

zamano.handleMessages(opts)

Express middleware for parsing mobile-originating (MO) SMS message requests from Zamano. Use the function as middleware in a app.get('') function to authenticate the request from Zamano and add a mobileMessage property to the request object:

app.get('/api/mo', 
  zamano.handleMessages({username: 'MO_USERNAME', password: 'MO_PASSWORD'}),
  function(req, res) {
    console.dir(req.mobileMessage)
    res.end()
})

Request authentication is done by passing the mobile-originating zamano username and password to the handleMessages function. NOTE this is a different username and password than the client id and password set at initialization. Contact your zamano representative if you have questions about your usernames and passwords.

If the options are not passed to the handleMessages function, no authentication will be performed. This means any requests will be accepted by the middleware. Note: zamano will always make a request from the same IP, which means you can choose to manually authenticate by IP address instead of using the username and password.

The mobileMessage object that is attached to the request has the following properties:

  • username - user's mobile-originating zamano id.
  • password - user's mobile-originating zamano password.
  • from - the originating mobile phone number.
  • to - the terminating number to which the message was sent.
  • text - the text of the message.
  • operatorId - The unique identifier of the Mobile Network Operator.

Note: Zamano's server expects a response from the mobile originating message request. If there is no response within 2 seconds, then the transaction will be considered failed.

For Shortcodes and Operator IDs, please refer to Zamano.

zamano-api's People

Contributors

jakepruitt avatar rjrodger avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

zamano-api's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.