Roger
Roger

Reputation: 365

Ruby functions to send Twilio fields from XML feed

I'm Ruby n00b, so please excuse my first question.

I've got my Rails environment up on a web server up, and now I am trying to find a Ruby functions (methods?) that would allow me to do the following:

Function 1

Function 2

Any suggestions on where to start would be helpful. (Even if it's to tell me to RTFM)

Upvotes: 0

Views: 66

Answers (1)

olive_tree
olive_tree

Reputation: 1457

For your first function, you don't need to do anything with Twilio. I presume you want to parse an XML feed to get specific data from it.

You can use a gem like nokogiri to parse XML, have a look at this similar SO question to learn how: Parsing XML with Ruby

There's tons of other resources on parsing XML using ruby here to: https://www.google.ca/search?q=parse+xml+ruby&rlz=1C1CHFX_enCA552CA552&oq=parse+xml+ruby&aqs=chrome..69i57j0l5.3359j0j7&sourceid=chrome&es_sm=122&ie=UTF-8

For your second function, this is where you'll actually be using Twilio. First off, I'm assuming you've setup Twilio, if not, head over to and sign up: https://www.twilio.com/

You'll want to add the Twilio ruby client in your Gemfile:

gem 'twilio-ruby'

Be sure to bundle install and if everything is good, you are ready to code your Twilio interaction. Assuming from fn1 you have the data in a variable, you'll now need to send it via SMS/MMS, here's the Twilio guide for that: https://www.twilio.com/docs/quickstart/ruby/sms/sending-via-rest

Upvotes: 3

Related Questions