gpt4 book ai didi

ruby-on-rails - 如何修复 "Twilio::REST::RestError"?

转载 作者:行者123 更新时间:2023-12-02 20:42:12 24 4
gpt4 key购买 nike

我按照此处的文档进行操作: https://www.twilio.com/blog/2016/04/receive-and-reply-to-sms-in-rails.html

现在我遇到以下错误:

Twilio::REST::RestError (Unable to create record: The requested resource /2010-04-01/Accounts//Messages.json was not found):

我的消息 Controller 代码是:

class MessagesController < ApplicationController 
skip_before_action :verify_authenticity_token
# skip_before_action :authenticate_user!, :only => "reply"

def reply
message_body = params["Body"]
from_number = params["From"]
init_twilio
msg = @client.messages.create(
from: Rails.application.secrets.twilio_number,
to: from_number,
body: "Hello! Your number is #{from_number}. This is a xxx
Test Message."
)

end

private

def init_twilio
account_sid = Rails.application.secrets.twilio_sid
auth_token = Rails.application.secrets.twilio_auth_key
@client = Twilio::REST::Client.new account_sid, auth_token
end
end

最佳答案

很难说给出的详细程度,但通常您的 Secrets.yml 文件中存在错误。仔细检查我们的 Twilio Keys 是否设置正确。

关于ruby-on-rails - 如何修复 "Twilio::REST::RestError"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45802757/

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