2015-01-18 3 views
1

특정 시간에 전화를 걸려고합니다. 다음 파이썬 코드는 호출한다 :Iron.io로 Twilio 통화 예약

#Download the library from twilio.com/docs/libraries 
from twilio.rest import TwilioRestClient 

# Get these credentials from http://twilio.com/user/account 
account_sid = "myaccountsid" 
auth_token = "myauthtoken" 
client = TwilioRestClient(account_sid, auth_token) 

# Make the call 
call = client.calls.create(to="+12345789123", # Any phone number 
          from_="+12345789123", # Must be a valid Twilio number 
          url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient") 
print call.sid 

를이 코드는 Iron.io에 사용되는 .worker입니다 :

# define the runtime language 
runtime "python" 

gem 'twilio-ruby' 
gem 'uber_config' 

# exec is the file that will be executed: 
exec "makecall.py" 

tutorial 사용.

/Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:103:in `eval': undefined method `gem' for #<IronWorkerNG::Code::Base:0x007fd6c5008ec8> (NoMethodError) 
    from (eval):4:in `block (2 levels) in initialize' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:103:in `eval' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:103:in `block (2 levels) in initialize' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/fetcher.rb:78:in `call' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/fetcher.rb:78:in `fetch' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:93:in `block in initialize' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:92:in `each' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/code/base.rb:92:in `initialize' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/cli.rb:78:in `new' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/lib/iron_worker_ng/cli.rb:78:in `upload' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/gems/iron_worker_ng-1.6.2/bin/iron_worker:120:in `<top (required)>' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/bin/iron_worker:23:in `load' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/bin/iron_worker:23:in `<main>' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/bin/ruby_executable_hooks:15:in `eval' 
    from /Users/user/.rvm/gems/ruby-2.0.0-p598/bin/ruby_executable_hooks:15:in `<main>' 

내가 잘못 뭐하는 거지 :

그러나, 나는 다음과 같은 예외가 발생?

+0

이것은 오타 (typo)입니다. 보석 이름은'twilio-ruby'입니다. – akonsu

+0

@akonsu는 제가 입력 한 것이 아닙니까? – Apollo

+0

자습서에 오타가 있다고 말하고 있습니다. 아마도 그들은 루비 버전에서 이식했을 것입니다. – akonsu

답변

2

파이썬 스크립트를 사용하여 .worker 파일에 Ruby gems를 사용하려는 것 같습니다. Python 라이브러리에는 pip를 사용해야합니다. .worker 파일을 다음으로 변경하십시오.

runtime 'python' 

# dependencies 
pip 'twilio' 

# executable 
exec 'mycall.py' 
+1

감사합니다. 이것은 많은 도움이되었습니다. – Apollo

관련 문제