我正在使用 twillio api 从我的应用程序发送短信。它工作正常。但是我需要将验证码作为短信发送来验证他的电话号码,然后需要从我的 rails 项目中提交注册。
任何人都可以提供使用 twilio 验证代码的示例示例。
谢谢
我正在使用 twillio api 从我的应用程序发送短信。它工作正常。但是我需要将验证码作为短信发送来验证他的电话号码,然后需要从我的 rails 项目中提交注册。
任何人都可以提供使用 twilio 验证代码的示例示例。
谢谢
这是 Twilio 的示例
require 'rubygems'
require 'twilio-ruby'
account_sid = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
auth_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
client = Twilio::REST::Client.new account_sid, auth_token
from = '+441702806101' # Your Twilio number
friends = {
'+447908232434' => 'David'
}
friends.each do |key, value|
client.account.sms.messages.create(
:from => from,
:to => key,
:body => "#{value} you are working 30/04/2013 - CX1"
)
puts "Sent message to #{value}"
end
请参阅 Ruby 中的代码完整教程:
https://www.twilio.com/docs/tutorials/walkthrough/account-verification/ruby/rails
希望这可以帮助