Created
June 29, 2012 04:21
-
-
Save jessieay/3015720 to your computer and use it in GitHub Desktop.
sends text messages using twilio gem
This file contains hidden or 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
require 'twilio-ruby' | |
class Texter | |
def initialize | |
@account_sid = 'xxx' | |
@auth_token = 'xxx' | |
@client = Twilio::REST::Client.new(@account_sid, @auth_token) | |
@from = 'xxx' | |
end | |
def sendSMS(to , body) | |
puts to | |
body_array=body.split('|') | |
body_array.slice!(5..-1) | |
body_array.each do |body| | |
@client.account.sms.messages.create( | |
:from =>@from, | |
:to => to, | |
:body => body | |
) | |
end | |
end | |
end | |
myText=Texter.new() | |
@me = 'xxx' | |
@ben = 'xxx' | |
myText.sendSMS(@ben, "testing testing | 123 ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment