0

I have a Training Management system in grails (grails version 2.0.4)

My Requirement

  1. Whenever user enrolls for training he must receive a sms alert to his mobile number given while registering.
  2. SMS to only Indian mobile phones (as we provide training only in india)
  3. One way SMS, from application to mobile (Reply not required)

Is there any good Plugins available in Grails? Even the java way of doing it will work fine in grails application.

maaz
  • 3,534
  • 19
  • 61
  • 100

3 Answers3

2

I have used Twilio for a partner's app. It is a paid service and the rates for international SMS to india are here.

There is a Grails plugin available for twilio but, I opted to write some custom code to send and receive messages. There were some issues with the plugin, which I don't remember.

The barebones code looked like:

def twilioHttpEndpointBean = new HTTPBuilder("https://api.twilio.com/2010-04-01/")
def sid = 'your SID here'
def auth_token = 'the auth token goes here'
twilioHttpEndpointBean.auth.basic(sid,auth_token)
def result = twilioHttpEndpointBean.request(Method.POST) { req -> 
    requestContentType = ContentType.URLENC
    uri.path = "Accounts/${sid}/SMS/Messages.json"
    body = [ To: <destinationPhoneNumber>, From: <mainNumberUsedToRegisterForTheService>, Body: 'your message' ]
    response.success = { resp, data ->
        def test = [status: data.status, sid: data.sid]
        return test
    }
    response.failure = { resp, data ->
        def test = [status: data.status, code: data.message]
        return test
    }
}
uchamp
  • 2,492
  • 1
  • 20
  • 31
1

There is A plugin, which provides an easy way to send SMS via the XMl-RPC API of the SMS-Gateway, sipgate.de, sipgate.com

install it using grails install-plugin sipgate command

and Edit account-data-placeholders in 'conf/Config.groovy'

grails.plugins.sipgate.username = 'YOUR_USERNAME'
grails.plugins.sipgate.password = 'YOUR_PASSWORD'
//According to E.164,

e.g. '4922112345678' grails.plugins.sipgate.phoneNumber = 'YOUR_PHONE'

then Inject the 'sipgateService' and send a SMS

def sipgateService
def phoneNumber = '4917712345678' //phoneNumber according to E.164 specification //working alternative: def phoneNumber = '+1-719-555-1234'
def result = sipgateService.sendSMS(phoneNumber, 'This is my Text to send!')
result? println 'Sending Successful': println 'Sending failed'
abdul
  • 1,531
  • 1
  • 14
  • 29
0

I am not sure about grail but if you want to give it a try by using java then check this out smslib.org.

Copied from the site:

SMSLib is a programmer library for sending and receiving SMS messages via a GSM modem or mobile phone.

Hope this helps you !!