在Ruby中接收电话号码输入

时间:2016-11-15 05:09:50

标签: ruby sinatra twilio twilio-api

应用程序使用REST API发送消息,但就其而言,“to”号码被硬编码到应用程序中。我希望该号码是用户输入的值。

HTML:

<!DOCTYPE html>
<head>
  <title>Joe's Web App</title>
  <link rel="stylesheet" type="text/css" href="index.css" media="screen"/>
</head>
<body>
  <div class="content">
    <div class="words">
      <h1>My Name</h1>
      <p>
        Insert your number below to recieve a text!
      </p>
    </div>
    <input type="tel" placeholder="Phone Number" name="number">
    <input type="submit">
  </div>
</body>

红宝石:

require 'rubygems'
require 'twilio-ruby'

account_sid = 'AC26b29f734e8145f6df3497eb6ca50205'
auth_token = 'my auth token'

@client = Twilio::REST::Client.new account_sid, auth_token

@client.account.messages.create({
  :from => 'Twilio Number',
  :to => 'phone number',
  :body => 'Hey this is Joe!',
})

1 个答案:

答案 0 :(得分:0)

如果你想使用sinatra,请用邮政路线包裹它。

原始代码应该是,

Fill