Skip to content

rreinold/twilio-sms-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ipm package: twilio-sms-library

Overview

Communication API for SMS

This is an ipm package, which contains one or more reusable assets within the ipm Community. The 'package.json' in this repo is a ipm spec's package.json, here, which is a superset of npm's package.json spec, here.

Browse ipm Packages

Setup

  1. Create an account on https://twilio.com
  2. Obtain your Username, Password, and Origin Number
  3. Configure your constants in the TwilioConstants library.
  4. Test using the example service TwilioExampleSendSMS.

Usage

This library gives user the ability to send sms using the Twilio API.

Assets

Code Libraries

  • TwilioSMSLib - Library for sending SMS Messages. It can be accessed using the Twilio object.

  • TwilioConstants - A constants library to have a centralized location for constants like API-key.

Code Services

Example

TwilioExampleSendSMS - An example service showing how to use the twilio library to send SMS.

Test

TwilioTestSetup - Tests if the constants for this package are set or not.

API

Typedefs

callback : function

This callback is displayed as part of this Library.

Twilio : Object

Sends a text message using Twilio's REST API.

callback : function

This callback is displayed as part of this Library.

Kind: global typedef

Param Type
err Object
resp Object

Twilio : Object

Sends a text message using Twilio's REST API.

Kind: global typedef

Param Type Description
user string Twilio API account ex. "BC218b72987d86855a5adb921370115a20"
pass string Twilio API passcode ex. "4579ac6ba4fae7b452c03c64aeae40e7"
sourceNumber string Origin phone number of text message, ex "(+1 512-713-2783)"

Example

var twconf = TWILIO_CONFIG;
var twilio = Twilio(twconf.USER, twconf.PASS, twconf.SOURCE_NUMBER);

Twilio.sendSMS(text, recipientNumber, callback)

Send SMS message

Kind: static method of Twilio

Param Type Description
text string text body
recipientNumber string Formatted phone number ex. "(+1 339-987-2816)"
callback callback ex. function(err, data){}

Example

var twconf = TWILIO_CONFIG;
var twilio = Twilio(twconf.USER, twconf.PASS, twconf.SOURCE_NUMBER);

twilio.sendSMS(text, recipientNumber, function(err, data){
    if(err){
        resp.error(err);
    }
    resp.success(data);
});

About

Communication API for SMS

Resources

Stars

Watchers

Forks

Packages

No packages published