Ruby on rails 4 Rails 4:通过语音通话验证在我的Rails应用程序中注册一个人
您能否分享一下,我如何向希望在我的Rails 4应用程序中注册并通过其语音进行验证的人拨打出站电话(简而言之,我希望通过语音呼叫验证在我的Rails应用程序中注册一个人),这是否可能通过twillo或建议其他方式实现 请一步一步地推荐或推荐一些教程/文档/视频 及 打电话要求验证:Ruby on rails 4 Rails 4:通过语音通话验证在我的Rails应用程序中注册一个人,ruby-on-rails-4,twilio,Ruby On Rails 4,Twilio,您能否分享一下,我如何向希望在我的Rails 4应用程序中注册并通过其语音进行验证的人拨打出站电话(简而言之,我希望通过语音呼叫验证在我的Rails应用程序中注册一个人),这是否可能通过twillo或建议其他方式实现 请一步一步地推荐或推荐一些教程/文档/视频 及 打电话要求验证: require 'twilio-ruby' # build up a response response = Twilio::TwiML::Response.new do |r|
require 'twilio-ruby'
# build up a response
response = Twilio::TwiML::Response.new do |r|
r.Say 'hello there, enter verification code', :voice => 'alice'
r.Dial :callerId => '+14159992222' do |d|
r.Gather :numDigits => '5', :action => "/verify_code?id=#{id}", :method => 'get' do |g|
g.Say 'Verified thankyou.' if verified?
else
# hangup or set behaviour
end
end
end
end
def verify_code
@verification = Verification.where(verification_code: params[:id]).first
if @verification
#activate
else
# Handle errors
end
end
最后,在您的模型中,您将需要生成验证代码的代码,并验证它是否被确认
class Verification < ActiveRecord::Base
before_create -> { self[:verification_code] = rand.to_s[2..5] }
end
类验证{self[:验证代码]=rand.to_s[2..5]}
结束