I am using twilio and get: error undefined method `account' for Twilio.
client = Twilio::REST::Client.new('twilio_sid','twilio_token')
# Create and send an SMS message
client.account.sms.messages.create(
from: "+12345678901",
to: user.contact,
body: "Thanks for signing up. To verify your account, please reply HELLO to this message."
)
You missed api
in your chain of calls. Try this:
client.api.account.messages.create(
from: "+12345678901",
to: user.contact,
body: "Thanks for signing up. To verify your account, please reply HELLO to
this message."
)
Would recommend reviewing Twilio's documentation here:
https://www.twilio.com/docs/guides/how-to-send-sms-messages-in-ruby
There have been some changes with Ruby Helper Library 5.x. (Note that the old version 4.x will only be supported until 10/15/17 - see deprecation notice.)
With 5.x, SMS can be sent as follows:
# set up a client to talk to the Twilio REST API
@client = Twilio::REST::Client.new(account_sid, auth_token)
@message = @client.messages.create(
from: '+15017250604',
to: '+15558675309',
body: 'This is the ship that made the Kessel Run in fourteen parsecs?'
)
My use of this approach has worked so far with twilio-ruby gem v5.2.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With