小编Zer*_*ber的帖子

Twilio仅返回本地计算机的身份验证错误

我的团队和我正在使用twilio发送短信.一切似乎在其他人的本地机器上运行正常(具有相同的确切代码),除了twilio总是向我返回一个验证错误.我正在将消息发送到他们的"特殊号码",因此它实际上不会发送真正的短信,但它仍会返回验证错误.

这是我们发送消息的一些代码:

def send_sms
  self.from_phone_number = CONFIG['live_twilio'] ? self.customer.assigned_phone_number : CONFIG['test_phone_number']
  self.to_phone_number   = CONFIG['live_twilio'] ? self.customer.customer_phone_number : CONFIG['test_phone_number']

  begin
    report_to_new_relic_insights
    send_message_with_twilio!
  rescue Twilio::REST::RequestError => e
    self.error_description = e.message
  end

  self.dispatched_at = Time.now
  self.save(validate: false)

  return e
end

def send_message_with_twilio!
  unless self.customer.example_customer?
    twilio_params = {
      from: "+1#{from_phone_number}",
      to:   "+1#{to_phone_number}",
      body: self.text
    }

    if ENV['RECORD_TWILIO_STATUSES'].in?(['1', 'true'])
      twilio_params[:status_callback] = "#{CONFIG['secure_domain']}/messages/#{id}/update_status"
    end

    client.account.messages.create(twilio_params)
  else
    # @onboarding_flow
    # don't send the actual SMS to the example customer
    self.customer.send_reply_as_example_customer! if self.customer.first_reply?
  end
end

def …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails twilio

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

标签 统计

ruby-on-rails ×1

twilio ×1