Java / Grails : Send SMS from application -
i have training management system in grails (grails version 2.0.4)
my requirement
- whenever user enrolls training must receive sms alert mobile number given while registering.
- sms indian mobile phones (as provide training in india)
- one way sms, application mobile (reply not required)
is there plugins available in grails? java way of doing work fine in grails application.
i have used twilio partner's app. paid service , rates international sms india here.
there grails plugin available twilio but, opted write custom code send , receive messages. there issues plugin, 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 } }
Comments
Post a Comment