Twilio 的未定义方法“帐户”
undefined method `account' for Twilio
我正在使用 twilio 并得到:错误 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."
)
您错过了您的呼叫链中的 api
。试试这个:
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."
)
应该是:
client.api.account.messages.create
建议在此处查看 Twilio 的文档:
https://www.twilio.com/docs/guides/how-to-send-sms-messages-in-ruby
Ruby 助手库 5.x 发生了一些变化。 (请注意,旧版本 4.x 仅在 2017 年 10 月 15 日之前得到支持 - 请参阅弃用通知。)
使用5.x,可以发送短信如下:
# 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?'
)
到目前为止,我对这种方法的使用在 twilio-ruby gem v5.2.1 上有效。
我正在使用 twilio 并得到:错误 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."
)
您错过了您的呼叫链中的 api
。试试这个:
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."
)
应该是:
client.api.account.messages.create
建议在此处查看 Twilio 的文档:
https://www.twilio.com/docs/guides/how-to-send-sms-messages-in-ruby
Ruby 助手库 5.x 发生了一些变化。 (请注意,旧版本 4.x 仅在 2017 年 10 月 15 日之前得到支持 - 请参阅弃用通知。)
使用5.x,可以发送短信如下:
# 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?'
)
到目前为止,我对这种方法的使用在 twilio-ruby gem v5.2.1 上有效。