gpt4 book ai didi

ruby-on-rails - Nexmo - Rails 中未定义的方法 send_message

转载 作者:行者123 更新时间:2023-12-03 15:56:54 25 4
gpt4 key购买 nike

我正在尝试使用 nexmo gem 发送短信,

直到几天前,代码运行良好。
enter image description here

def send_sms
@number = params[:number]
@nannytel = params[:phone]
nexmo = Nexmo::Client.new(
key: 'xxxxxxx',
secret: 'xxxxxxx'
)

notification = "The contact number is following #{@nannytel}"

response = nexmo.send_message(
from: "SENDERID",
to: @number,
text: notification
)

if response['messages'].first['status'] == '0'
flash[:success] = "Yayy! 🎉 We just sent you details for the nanny 😍"
redirect_to root_path
else
flash[:alert] = "Uh Oh! Something went wrong, please try entering your number again"
redirect_to root_path
end
end

以上是 pages Controller 中的方法

最佳答案

请修改以下代码

response = nexmo.send_message(
from: "SENDERID",
to: @number,
text: notification
)

作为
response = nexmo.sms.send(
from: "SENDERID",
to: @number,
text: notification
)

根据 documentation 需要进行上述更改版本 5.0.2
或者

使用版本 4.8而不是 5.0.2
gem 'nexmo', '4.8'

关于ruby-on-rails - Nexmo - Rails 中未定义的方法 send_message,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49586225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com