Skip to content

Instantly share code, notes, and snippets.

@eshleebien
Forked from jekku/talkative-octo-pussy.md
Created November 17, 2015 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eshleebien/ea740ab8fc741fe341bf to your computer and use it in GitHub Desktop.
Save eshleebien/ea740ab8fc741fe341bf to your computer and use it in GitHub Desktop.
Sending an SMS thru the Chikka SMS API

##Module that sends an SMS thru the Chikka API

'use strict';

var util = require('../../helpers/util'),
    superagent = require('superagent'),
    config = {
        endpoint : 'https://post.chikka.com/smsapi/request',
        shortcode : /*Your shortcode here*/,
        client_id : /*Your client_id here*/,
        secret_key : /*Your secret_key here*/
    };
    
exports.send_sms = function (message, mobile_number, callback){
    var daily_id = util.random_id(32);
    
    superagent.post(config.endpoint)
            .set('mobile_number', mobile_number)
            .set('shortcode', config.shortcode)
            .set('message_id', daily_id)
            .set('client_id', config.client_id)
            .set('secret_key', config.secret_key)
            .end(callback);
};

##Contents of util.js

'use strict';

exports.random_id = function (length) {
    return '' + (Math.random() * Math.pow(10,16));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment