我正在创建一个使用Devise的Rails应用程序。 我试图使用Ngrok在我的网站上添加Twilio消息功能,我使用了这个教程: https://www.twilio.com/blog/2016/04/receive-and-reply-to-sms-in-rails.html
我能够在控制台中打开Ngrok,并获取他们为我的URL提供的web-id。 当我将URL插入浏览器时,我一直收到此错误..我应该进入自己的本地Rails应用程序。不确定出了什么问题。
我在我的ngrok消息控制器中添加了以下内容:
class MessagesController < ApplicationController
skip_before_filter :verify_authenticity_token
skip_before_filter :authenticate_user!, :only => "reply"
def reply
message_body = params["Body"]
from_number = params["From"]
boot_twilio
sms = @client.messages.create(
from: Rails.application.secrets.twilio_number,
to: from_number,
body: "Hello there, thanks for texting me. Your number is #{from_number}."
)
#twilio expects a HTTP response to this request
end
private
def boot_twilio
account_sid = Rails.application.secrets.twilio_sid
auth_token = Rails.application.secrets.twilio_token
@client = Twilio::REST::Client.new account_sid, auth_token
end
end
我真的不确定问题出在哪里。 当它不能连接到“def reply”和authenticate_user应该由devise定义。
@client = Twilio::REST::Client.new account_sid, auth_token
。 - DianaBGgem 'twilio-ruby'
添加到您的Gemfile中,运行bundle install
,然后再试一次。 - philnash