Giter Club home page Giter Club logo

ti.twilio's Introduction

Ti.Twilio

Cross-Platform common.js library for using Twilio SMS Services

Requirements

  • Axway Titanium SDK
  • Twilio Account. (You can get started with $15 of free credit for dev/test)
    • Twilio 'Account SID' (Two environments will get created: 'LIVE' and 'TEST')
    • Twilio 'Phone #' (for 'LIVE' you pick your own free number. for 'TEST' you must use '+15005550006')
  • Twilio REST API (https://www.twilio.com/console/video/dev-tools/api-keys)
    • Twilio 'API SID'
    • Twilio 'API Secret'

Usage

Copy /lib/ti.twilio.js to your /lib folder

Add Module and initialize

  • AccountSID, APISID, & APISecret = All {strings} from your Twilio Account
  • timeout = {integer} to define API timeout in milliseconds
  • FROM_PhoneNumber = {string} in E.164 format of phone # to send message FROM (ie. +15005550006')

NOTE: FROM_PhoneNumber passed in must match the API Key Environment (as mentioned above)

var twilioClient = require('ti.twilio');
twilioClient.init('AccountSID', 'APISID', 'APISecret', 'FROM_PhoneNumber', timeout);

Send SMS Message

  • Message = {string} message to send to user
  • TO_PhoneNumber = {string} in E.164 format of client phone # to send message TO (ie. +146921439389')
  • successCallback = {function} to execute upon success
  • failureCallback = {function} to execute upon failure
twilioClient.sendSMS(Message, TO_PhoneNumber, successCallback, failureCallback);

Example

//index.js

var twilioClient = require('ti.twilio');
twilioClient.init('AABBCCDDEEFF1122334455', 'GGHHIIJJKK6677889900', 'LLMMNNOOPPQQ22446688', '+5005550006', 6000);
function testSMS(){
	twilioClient.sendSMS('Test SMS Message', '+14692143989', successCallback, failureCallback);
}

function successCallback(e){
	alert("Success") + JSON.stringify(e);
}
function failureCallback(e){
	alert("Opps....something went wrong\n" + JSON.stringify(e));
}

ti.twilio's People

Contributors

adamtarmstrong avatar

Watchers

James Cloos avatar Swanand Marathe avatar

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.