Last active
August 29, 2015 14:07
-
-
Save chris3000/48fa4661e30d0927e8bd to your computer and use it in GitHub Desktop.
send a "mood" picture to a user using the Twilio API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ck987_mms] | |
exten => s,1,Background(/home/ck987/asterisk_sounds/moods) | |
same => n,WaitExten(10) | |
exten => 1,1,System(/home/ck987/ruby/mms_send.rb ${CALLERID(num)} grumpy) | |
same => n,Hangup | |
exten => 2,1,System(/home/ck987/ruby/mms_send.rb ${CALLERID(num)} happy) | |
same => n,Hangup | |
exten => 3,1,System(/home/ck987/ruby/mms_send.rb ${CALLERID(num)} excited) | |
same => n,Hangup | |
exten => 4,1,System(/home/ck987/ruby/mms_send.rb ${CALLERID(num)} sad) | |
same => n,Hangup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'twilio-ruby' | |
#usage: mms_send.rb <phone-number> <mood> | |
#example: mms_send.rb 12125551212 grumpy | |
@account_sid = "xxx" # your account SID here | |
@auth_token = "xxx" # your authtoken here | |
@from_number = "1917xxxxxx"# your twilio phone number here | |
@to_number = ARGV[0] # the number that will receive the sms | |
# set up a client to talk to the Twilio REST API | |
@client = Twilio::REST::Client.new(@account_sid, @auth_token) | |
moods = { :happy => "http://i.imgur.com/aQvVqVZ.gif", | |
:grumpy => "http://i.imgur.com/VE6KwSq.jpg", | |
:excited => "http://i.imgur.com/Bq7Mpak.jpg", | |
:sad => "http://i.imgur.com/tM7fWA7.jpg" } | |
mood = ARGV[1] | |
mood_url = moods[mood.to_sym] | |
@account = @client.account | |
@message = @account.messages.create({ :from => @from_number, | |
:to => @to_number, | |
:body => 'Here\'s your mood.', | |
:media_url => mood_url }) | |
puts @message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment