2013-06-11 4 views
0

Twilio 레일 앱에서 SMS를 보낼 수없는 것 같습니다. 다음은 Twilio Smss를 처리하도록 구성된 컨트롤러입니다.Rubil on Rails로 Twilio Sms 보내기

내 Twilio 번호를 호스팅하는 localtunnel을 사용하여이 메시지를 재생할 때 smss가 수신되고 Sms 클래스 인스턴스가 올바르게 생성됩니다. 그러나 else 블록에 들어가면 실제로 응답 SMS를 보내지 않습니다. 숫자는 @ sms.from에 있으며 '+ 1xxxxxxxxxx'형식의 단순한 셀입니다. 이 아이디어가 효과가없는 이유는 무엇입니까? 자신의 API를 확인한 결과, T를 따르고있는 것으로 보입니다.

class SmsController < ApplicationController 
    def index 

    end 

    def create 

    @sms = Sms.create(:from => params['From'], :body=> params['Body'], :to=>params["To"], :uri=>params['Uri']) 

    if Answer.exists?(params['Body'].to_i) 
     @answer = Answer.find(params['Body'].to_i) 
     binding.pry 
     @answer.upvote 
    else 
     @message = client.account.sms.messages.create(
     :from => '+13473217539', 
     :to => @sms.from, 
     :body => "Sorry that wasn't a valid option" 
    ) 
     puts @message 
     binding.pry 
    end 
    render :nothing => true 
    end 

end 

답변

0

이 보석은 Twilio 클라이언트를 방해합니다. 개발에 사용하지 마십시오

group :development, :test do 
    gem 'sms-spec' 
1
require 'rubygems' 
require 'net/smtp' 
require 'sendsms' 

w2s = SendSms.new "username","password" 
w2s.send "send number", "sms content"