Skip to content

Instantly share code, notes, and snippets.

@aspencer8111
Last active December 15, 2015 18:09
Show Gist options
  • Save aspencer8111/5301947 to your computer and use it in GitHub Desktop.
Save aspencer8111/5301947 to your computer and use it in GitHub Desktop.
A quick ruby script to send text msgs to my friends - uses twilio
require 'rubygems'
require 'twilio-ruby'
account_sid = "<<>>"
auth_token = "<<>>"
client = Twilio::REST::Client.new account_sid, auth_token
from = "+<<>>" # Your Twilio number
# "Kile" => "+<<>>",
# "Cassie" => "+<<>>"
friends = {
"Alex" => "+<<>>",
"Brent" => "+<<>>",
"Keri" => "+<<>>",
"Karen" => "+<<>>"
}
puts "Who would you like to send a message to? Options are: Keri, Kile, Cassie, Brent, Karen, Alex, or ALL"
to = gets.chomp
puts "What would you like the message to be?"
message = gets.chomp
number = friends[to]
if to == "ALL"
friends.each do |friend|
client.account.sms.messages.create(
:from => from,
:to => friend[1],
:body => "#{message} - This is an automated text from a script written by Alex S. Twilio API :-)")
puts "Message has been sent to #{friend[0]}"
end
else
client.account.sms.messages.create(
:from => from,
:to => friends[to],
:body => "#{message} - This is an automated text from a script written by Alex S. Twilio API :-)")
puts "Message has been sent"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment