Plugins You can find out about all the publicly available Grails plugins.

Twilio Plugin

  • Tags: /
  • Latest: 0.1
  • Last Updated: 20 March 2015
  • Grails version: 2.4 > *
0 vote
Dependency:
compile ":twilio:0.1"

 Documentation  Source  Issues

Summary

Grails plugin for integration with Twilio SMS Gateway api.

Installation

grails install-plugin twilio

Description

Twilio Grails</h1>

Description

The twilio-grails plug-in provides sms sending capability to a Grails application via twilio api.

Configuration

Add your twilio properties to grails configuration file: Example Assuming you have a twilio account, then add the required information to your grails config file.

twilio {
        // Enter your host address
        host = 'https://api.twilio.com'
        apiID = 'enter your api Id'
        apiPass = 'enter your api password'
        smsUrl = '/2010-04-01/Accounts/' + apiID + '/Messages.json'
        number = ""
    }

BuildConfig.groovy

Copy and paste the following to your BuildConfig.groovy File
compile(group:'org.apache.httpcomponents',name:'httpclient',version:'4.3.6')
         compile(group:'org.apache.httpcomponents',name:'fluent-hc',version:'4.3.6')
         compile(group:'org.apache.httpcomponents',name:'httpclient-cache',version:'4.3.6')
         compile(group:'org.apache.httpcomponents',name:'httpmime',version:'4.3.6')

Usage

Inject smsService into your class

def smsService

_smsService_ is a Grails service that provides a method called send() that can take mapped parameters. Please note that send() is overloaded see http://en.wikipedia.org/wiki/Function_overloading and can take various variations of parameters.

One simple form is:

send(Map map)

Where ......

map contains parameters… br. map.to: phone number of recipient eg +1234444444

map.from: your twilio assigned number eg. +09899898989

map.body: "The body of your message" map.mediaUrl: "Url for any attachment" (optional )

Example

An example usage can be seen below.

Class YourController{

def smsService … def yourMethod(){ def map = [to:"070987878787",from:"09808000000",body:"SMS BODY"] smsService.send(map)

}

}