小编cod*_*fun的帖子

如何修复“Twilio::REST::RestError”?

我遵循了这里的文档: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):
Run Code Online (Sandbox Code Playgroud)

我的消息控制器代码是:

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
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails twilio

1
推荐指数
1
解决办法
2432
查看次数

标签 统计

ruby-on-rails ×1

twilio ×1