Twilio :: REST :: RequestError:' To'号码不是有效的电话号码

时间:2017-05-06 15:50:22

标签: ruby-on-rails ruby twilio

无论出于何种原因,textris gem正在删除" +"。我怎么能阻止这个?

class UserTexter < Textris::Base
  default :from => "+15616005697"

  def welcome(user)
    @user = user
    text :to => '+' + @user.number # I've also tried hardcoding "+447576912465"
  end
end

控制台

UserTexter.welcome(u)
+447576912465 # See it has the plus in it
  Rendered user_texter/welcome.text.erb (0.2ms)
=> #<Textris::Message:0x007fbbffc12ee8
 @action=:welcome,
 @content="Welcome to our system!",
 @from_name="L.T.C.",
 @from_phone="17864206788",
 @texter=UserTexter,
 @to=["447576912465"]> # but then it doesn't show here
[18] pry(main)> UserTexter.welcome(u).deliver
+[+447576912465]
  Rendered user_texter/welcome.text.erb (0.6ms)
Twilio::REST::RequestError: The 'To' number 447576912465 is not a valid phone number. # hence why I get the error here
from /Users/galli01anthony/.rvm/gems/ruby-2.1.3/gems/twilio-ruby-4.11.1/lib/twilio-ruby/rest/base_client.rb:125:in `connect_and_send'

welcome_text.erb

<p>Test Text</p>

我该如何解决这个问题?问题的根源是什么?我使用twilio gem连接到Twilio API。

1 个答案:

答案 0 :(得分:2)

检查您的Twilio帐户是否处于试用模式。

如果您的帐户处于试用模式,则只能向已验证的号码发送短信。