0

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

  • suck in an XML feed from another website
  • cherry pick a particular field from that XML field (e.g. email addr or phone)

Function 2

  • send that particular XML field to phone number via Twilio.

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

Roger
  • 365
  • 2
  • 18
  • You need to read the docs on Twilio and you need to learn about Xpath or whatever the Ruby equivalent is to parse XML. Hope this helps. – Casey Aug 10 '14 at 00:39
  • Cool; thanks, emodendroket. I will look that up. – Roger Aug 11 '14 at 03:39

1 Answers1

3

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

Pang
  • 9,564
  • 146
  • 81
  • 122
olive_tree
  • 1,417
  • 16
  • 23
  • Awesome, thanks! (Tried to vote this up, but don't have enough credit / brownie points). – Roger Aug 11 '14 at 02:43