Wednesday, 9 January 2013

Twilio for rails - setting the StatusCallback URL

I've been using Twilio with Rails to send SMS, and needed Twilio to notify my Rails app if a send had been successful or not.

To acheive this I added a StatusCallback parameter when calling message.create. This contains a URL with a unique identifier of the message I sent.

 # send an sms
    @client.account.sms.messages.create(
        :from => '+44207XXXXXX',
        :to => phoneNumber,
        :body => body,
        :StatusCallback => ENV['app_url']+ENV['twilio_sms_postback']+'?smsId='+textmessageId.to_s
    )

No comments:

Post a Comment

Comments are moderated, so you'll have to wait a little bit before they appear!