twilio-ruby gem 是否采用 'from'、'to' 和 'url' 以外的参数?打电话的时候? [英] Does the twilio-ruby gem take parameters other than 'from', 'to', and 'url' when making calls?

查看:52
本文介绍了twilio-ruby gem 是否采用 'from'、'to' 和 'url' 以外的参数?打电话的时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https://github.com/twilio/twilio-ruby/blob/master/lib/twilio-ruby/rest/calls.rb,似乎只使用了from"、to"和url".如何传递IfMachine"的值?例如,以下内容似乎不起作用.

Looking at https://github.com/twilio/twilio-ruby/blob/master/lib/twilio-ruby/rest/calls.rb, it appears that only 'from', 'to', and 'url' are used. How do I pass a value for 'IfMachine'? For example, the following doesn't seem to work.

# set ACCOUNT_SID and AUTH_TOKEN

twilioClient = Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN)
twilioAccount = twilioClient.account
twilioAccount.calls.create({
    :from => 'from_number',
    :to => 'to_number',
    :url => '/url',
    'IfMachine' => 'Hangup'
})

# IfMachine parameter is not passed in the above request

推荐答案

设置 'IfMachine' => 'hangup' 对我有用.我认为 Twilio API 对参数值区分大小写.所以挂断"会起作用,但挂断"可能不会.

Setting 'IfMachine' => 'hangup' works for me. I think the Twilio API is case-sensitive with respect to parameter values. So 'hangup' would work but 'Hangup' probably won't.

这是我的 twilio-ruby 会话,显示参数已正确传递:

Here's my twilio-ruby session showing that the parameters are passed correctly:

irb(main):002:0> c.account.calls.create :from => '2158377932', :to => '4159334335', :url => 'http://demo.twilio.com/welcome/voice', 'IfMachine' => 'continue'
warning: peer certificate won't be verified in this SSL session
=> <Twilio::REST::Call @uri=/2010-04-01/Accounts/AC8faaf6f7efb9dfd60bc0ff3aa7fa00be/Calls/CA0165c3b35c934ed5a2b7a87f343544ff>
irb(main):003:0> c.last_request
=> #<Net::HTTP::Post POST>
irb(main):004:0> req = c.last_request
=> #<Net::HTTP::Post POST>
irb(main):005:0> req.body
=> "IfMachine=continue&To=4159334335&Url=http%3a%2f%2fdemo.twilio.com%2fwelcome%2fvoice&From=2158377932"

这篇关于twilio-ruby gem 是否采用 &amp;#39;from&amp;#39;、&amp;#39;to&amp;#39; 和 &amp;#39;url&amp;#39; 以外的参数?打电话的时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆