2016-11-15 1 views
-2

앱이 REST API를 사용하여 메시지를 보내지 만 "받는 사람"번호는 앱에 하드 코딩되어 있습니다. 그 숫자를 사용자가 입력 한 값으로하고 싶습니다.루비에 전화 번호 입력 받기

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!', 
}) 
+0

은 당신이 랙 구축하면 간단 할 거라고 생각해. 자세한 내용은 .. https://codenoble.com/blog/ruby-web-applications-without-rails/ –

+0

그래서 당신은 sinatra 또는 이것을 구현하고 싶습니까? – marmeladze

+0

스택 오버플로에 오신 것을 환영합니다. 그것은 당신이 원하는 것을 완전히 명확하지 않습니다. –

답변

0

, 포스트 경로로 포장.

원시 코드가 있어야

post '/send_message' do 
    @client = Twilio::REST::Client.new account_sid, auth_token 
    @client.account.messages.create({ 
    from: 'Twilio Number', 
    to: params[:number], 
    body: 'Hey this is Joe!', 
    }) 

end