我正在构建一个 Rails 应用程序(基于印度以外),我需要在其中向已确认预订的用户发送短信。为此,我在 Twilio 上使用了试用帐户。但是,当我尝试发送短信时,状态始终显示为“待处理”,并且我没有收到发往所需目的地号码的短信。可能是什么原因?
我使用以下代码创建了一个 notification_controller:
class NotificationController < ApplicationController
skip_before_action :verify_authenticity_token
def notify
client = Twilio::REST::Client.new 'my_account_SID', 'my_account_Token'
message = client.account.messages.create from: 'twilio_number_assigned', to: 'my_number', body: 'Learning to send SMS you are.'
render plain: message.status
end
end
并向 /notifications/notify 发出 POST 请求。
更新:
如果您的 Rails 应用程序有另一个批量短信提供商服务,请随时分享相关文档。谢谢!