如何使用 Rails 配置 Twilio 短信网关?
我正在尝试在我的应用程序中使用 Twilio 短信网关来发送和接收短信。使用的代码如下:
ACCOUNT_SID = 'accountsidgoeshere'
ACCOUNT_TOKEN = 'token'
CALLER_ID = '(415) 599-2671'
req_params = {
'From' => CALLER_ID,
'To' => params[:number],
'Body' => 'This is message body'
}
account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)
resp= account.request("/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages",'POST', req_params)
作为回应,我得到以下信息:
您尝试使用沙盒号码向未经验证的电话号码发送消息。请验证您尝试向其发送消息的号码,或者升级您的帐户并购买一个号码来使用。
我正在传递号码:已通过 Twilio 网站验证的手机号码。
任何提示和指示都会对我有很大帮助。
I am trying to use the Twilio sms gateway in my application to send and receive sms. The used code is given below:
ACCOUNT_SID = 'accountsidgoeshere'
ACCOUNT_TOKEN = 'token'
CALLER_ID = '(415) 599-2671'
req_params = {
'From' => CALLER_ID,
'To' => params[:number],
'Body' => 'This is message body'
}
account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)
resp= account.request("/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages",'POST', req_params)
In response I am getting the following:
You have attempted to use the Sandbox number to send a message to an unverified phone number. Please verify the number to which you are attempting to send a message, or Upgrade your account and buy a number to use instead.
I am passing the number:mobile number which is already verified by the Twilio site.
Any hints and pointers will be a great help for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来像是您的帐户或您传入的帐户 ID 的配置问题。您应该检查 Twilio 以获得具体帮助,并且您应该能够检查那里的日志以了解出了什么问题。
Twilio 帮助
Sounds like a configuration issue with your account or with the account ID you are passing in. You should check w/ Twilio to get specific help and you should be able to check the logs there to get an idea of what's going wrong.
Twilio Help
使用短信和/或呼叫 Twilio 功能,您需要有 经过验证的美国号码。 (我猜,Twilio 通过拨打该号码来处理验证。)
如果您没有来自美国的经过验证的号码,另一种选择是从 Twilio 购买号码。
To use SMS and/or call features from Twilio you need to have a verified US number. (I guess, Twilio processes verification by calling the number.)
Another option is to buy a number from Twilio if you dont have a verified number from US.
您是否传递格式为 E.164 的号码?
Are you passing the number formatted as E.164?