本文整理汇总了Python中twilio.twiml.Response.dial方法的典型用法代码示例。如果您正苦于以下问题:Python Response.dial方法的具体用法?Python Response.dial怎么用?Python Response.dial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twilio.twiml.Response
的用法示例。
在下文中一共展示了Response.dial方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: conference
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def conference(request, name, muted=None, beep=None,
start_conference_on_enter=None, end_conference_on_exit=None,
wait_url=None, wait_method=None, max_participants=None):
"""See: http://www.twilio.com/docs/api/twiml/conference.
Usage::
# urls.py
urlpatterns = patterns('',
# ...
url(r'^conference/?(P<name>\\w+)/$', 'django_twilio.views.conference',
{'max_participants': 10}),
# ...
)
"""
r = Response()
r.dial().conference(
name = name,
muted = muted,
beep = beep,
startConferenceOnEnter = start_conference_on_enter,
endConferenceOnExit = end_conference_on_exit,
waitUrl = wait_url,
waitMethod = wait_method,
)
return r
示例2: handle_ringdown
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def handle_ringdown():
stack = request.args.getlist('stack')
sorry = request.args.get('sorry', 'Sorry, no one answered')
if len(stack) == 0:
# Nothing else to ringdown
resp = Response()
resp.say(sorry)
return str(resp)
top = stack.pop(0)
data = {
'stack': stack,
'sorry': sorry
}
qs = urlencode(data, True)
resp = Response()
resp.dial(top, timeout=10, action="/ringdown/handle?{}".format(qs),
method='GET')
return str(resp)
示例3: call_reference
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def call_reference(request):
r = Response()
if request.GET['key'] == settings.TWILIO_KEY:
kwargs = {'number':'+447513623450', 'action':None, 'method':None, 'timeout':settings.TWILIO_TIMEOUT, 'hangupOnStar':False,'timeLimit':None, 'callerId':None,'record':True}
r.dial(**kwargs)
kwargs = {'text':settings.ENDCALL, 'voice':None, 'language':None, 'loop':None}
r.say(**kwargs)
return r
示例4: conference
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def conference(request):
response = Response()
response.dial().conference(
name=request.REQUEST['room'],
startConferenceOnEnter=True,
endConferenceOnExit=True
)
return response
示例5: testSipUsernamePass
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def testSipUsernamePass(self):
""" should redirect the call """
r = Response()
d = r.dial()
d.sip('[email protected]', username='foo', password='bar')
r = self.strip(r)
assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Sip password="bar" username="foo">[email protected]</Sip></Dial></Response>')
示例6: test_add_queue
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def test_add_queue(self):
""" add a queue to a dial """
r = Response()
d = r.dial()
d.append(twiml.Queue("The Cute Queue"))
r = self.strip(r)
assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Queue>The Cute Queue</Queue></Dial></Response>')
示例7: handle_twilio_request
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def handle_twilio_request():
"""Respond to incoming Twilio requests."""
now = strftime("%Y-%m-%d %H:%M:%S", gmtime())
call_number = request.args.get('Called')
call_number = phonenumbers.parse("+" + call_number, None)
call_number = phonenumbers.format_number(call_number, phonenumbers.PhoneNumberFormat.E164)
agent = models.Agent.query.filter_by(phone=call_number).first()
conference_name = '{time}-{name}'.format(time=now, name=agent.username)
response = Response()
with response.dial() as r:
r.conference(conference_name,
beep=False, waitUrl='', startConferenceOnEnter="true",
endConferenceOnExit="true")
conf = models.Conference(name=conference_name, status="waiting", agent_id=agent.id)
models.add(conf)
models.commit()
return str(response)
示例8: testSip
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def testSip(self):
""" should redirect the call """
r = Response()
d = r.dial()
d.sip('[email protected]')
r = self.strip(r)
assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Sip>[email protected]</Sip></Dial></Response>')
示例9: testSipUri
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def testSipUri(self):
""" should redirect the call"""
r = Response()
d = r.dial()
s = d.sip()
s.uri('[email protected]')
r = self.strip(r)
self.assertEquals(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Sip><Uri>[email protected]</Uri></Sip></Dial></Response>')
示例10: dial
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def dial(request, number, action=None, method='POST', timeout=None,
hangup_on_star=None, time_limit=None, caller_id=None):
"""See: http://www.twilio.com/docs/api/twiml/dial.
Usage::
# urls.py
urlpatterns = patterns('',
# ...
url(r'^dial/?(P<number>\\w+)/$', 'django_twilio.views.dial'),
# ...
)
"""
r = Response()
r.dial(number=number, action=action, method=method, timeout=timeout,
hangupOnStar=hangup_on_star, timeLimit=time_limit,
callerId=caller_id)
return r
示例11: setUp
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def setUp(self):
r = Response()
with r.dial() as dial:
dial.queue("TestQueueAttribute", url="", method='GET')
xml = r.toxml()
#parse twiml XML string with Element Tree and inspect
#structure
tree = ET.fromstring(xml)
self.conf = tree.find(".//Queue")
示例12: setUp
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def setUp(self):
r = Response()
with r.dial() as dial:
dial.conference("TestConferenceAttributes", beep=False, waitUrl="",
startConferenceOnEnter=True, endConferenceOnExit=True)
xml = r.toxml()
#parse twiml XML string with Element Tree and inspect structure
tree = ET.fromstring(xml)
self.conf = tree.find(".//Dial/Conference")
示例13: handle_call
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def handle_call(conference_id):
conference = models.Conference.query.get(conference_id)
response = Response()
with response.dial() as r:
r.conference(conference.name,
beep=False, waitUrl='', startConferenceOnEnter="true",
endConferenceOnExit="false")
return str(response)
示例14: handle_opt
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def handle_opt():
response = Response()
digit = request.form["Digits"]
opt = request.args.get("opt_" + digit, None)
if opt is None:
response.say(err_say)
response.redirect("{}?{}".format(request.base_url, request.query_string))
return str(response)
opt_args = opt.split(":")
if opt_args[0] == "Call":
response.dial(opt_args[2])
elif opt_args[0] == "Info":
response.say(opt_args[2], voice=voice)
response.say(end_say, voice=voice)
return str(response)
示例15: answer_call
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import dial [as 别名]
def answer_call():
r = Response()
if request.form['From'] != config.intercom:
r.reject(reason='rejected')
if not config.auth:
r.verbs.extend(grant_access())
else:
with r.gather(action=url_for('.check_input'), numDigits=4, timeout=4) as g:
g.say('Please enter a pin or hold.')
try:
contact = models.Contact.objects.get(pk=config.forward)
r.dial(contact.phone_number)
except models.Contact.DoesNotExist:
pass
r.say('Goodbye.')
return r