Skip to content

Instantly share code, notes, and snippets.

@mehlah
Created October 14, 2015 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehlah/d3c42db5fcf01f3d0936 to your computer and use it in GitHub Desktop.
Save mehlah/d3c42db5fcf01f3d0936 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'time_diff'
require 'twilio-ruby'
TWILIO_SID = 'twilio_sid'
TWILIO_TOKEN = 'twilio_token'
TWILIO_PHONE_NUMBER = '+447903570595'
class TwilioApi
def client
@client ||= Twilio::REST::Client.new(TWILIO_SID, TWILIO_TOKEN)
end
def send_sms(recipient_phone:, message_body:)
client.messages.create(
from: TWILIO_PHONE_NUMBER,
to: recipient_phone,
body: message_body
)
end
end
twilio = TwilioApi.new
countdown = Time.diff(Time.now, Time.parse('2015-10-21 20:00'), '%d, %h hours and %m minutes')
twilio.send_sms(recipient_phone: '+33670031030', message_body: "In #{countdown[:diff]} you'll talk at Web en Vert!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment