本文整理汇总了Python中twilio.twiml.Response.play方法的典型用法代码示例。如果您正苦于以下问题:Python Response.play方法的具体用法?Python Response.play怎么用?Python Response.play使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twilio.twiml.Response
的用法示例。
在下文中一共展示了Response.play方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_third_response
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def handle_third_response(request):
digits = request.POST.get('Digits', '')
twilio_response_three=Response()
#twilio_response_three.say(digits)
twilio_response_three.play('http://travellingscholar.com/ammi/message6.mp3')
twilio_response_three.gather(action='respond4', numDigits=1)
return twilio_response_three
示例2: handle_response_digits
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def handle_response_digits(request):
twilio_request = decompose(request)
digits = twilio_request.digits
twilio_response = Response()
if digits == '2':
# twilio_response.play('http://bit.ly/phaltsw')
number = request.POST.get('From', '')
twilio_response.say('A text message is on its way. Daaaaaaaaaaaaaaamn Daniel! Peace out yo')
twilio_response.sms('Daaaaaaaaaaaaaaamn Daniel!', to=number)
elif digits == '1':
# twilio_response.play('http://bit.ly/phaltsw')
# twilio_response.play('https://p.scdn.co/mp3-preview/934da7155ec15deb326635d69d050543ecbee2b4')
# twilio_response.play('https://p.scdn.co/mp3-preview/934da7155ec15deb326635d69d050543ecbee2b4')
twilio_response.play('https://demo.twilio.com/hellomonkey/monkey.mp3')
# number = request.POST.get('From', '')
# twilio_response.say('I got you bruh, sending you a text in a bit. PEACE!')
# twilio_response.sms('You looking lovely today!', to=number)
elif digits == "3":
twilio_response.say("Record your monkey howl after the tone.")
twilio_response.record(maxLength="5", action="/handle_recording")
# If the caller pressed invalid input
else:
# twilio_response.say('Incorrect Number Pressed')
return redirect("/gather")
return twilio_response
示例3: handle_fourth_response
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def handle_fourth_response(request):
digits = request.POST.get('Digits', '')
number = request.POST.get('From','')
twilio_response_four=Response()
#twilio_response_four.say(digits)
twilio_response_four.play('http://travellingscholar.com/ammi/message7a.mp3')
twilio_response_four.sms('Your newborn will need lots of food to grow. The best food for your newborn is your breastmilk. Feeding her honey or ghee is harmful and a waste of your special milk.', to=number)
return twilio_response_four
示例4: echo
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def echo(request):
response = Response()
if request.method == 'POST':
response.play(request.POST['RecordingUrl'])
else:
response.say("Echo test", voice='woman')
response.record()
return response
示例5: gather_digits
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def gather_digits(request):
twilio_response = Response()
twilio_response.play('http://travellingscholar.com/ammi/message1.mp3')
twilio_response.play('http://travellingscholar.com/ammi/message2.mp3')
with twilio_response.gather(action='respond', numDigits=1) as g:
#g.say('Assalaam walaikum, Ammi Tips par khush amdeed')
#g.say(request)
g.pause(length=1)
return twilio_response
示例6: handle_response
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def handle_response(request):
digits =request.POST.get('Digits','')
twilio_response =Response()
if digits =='1':
twilio_response.play('http://bit.ly/phaltsw')
if digits=='2':
number=request.POST.get('FROM','')
twilio_response.say('A text message is on its way')
twilio_response.sms('You looking lovely today!', to=number)
return twilio_response
示例7: get
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def get(self, request, client_call, pk):
call = ClientCall.objects.get(pk=client_call)
url = reverse("phone:verify_shelter_availability", kwargs={"pk": pk, "client_call": client_call})
r = Response()
r.say("Hello, this is the Continuum, calling on behalf of")
r.play(call.client_name)
r.say("who is near")
r.play(call.location_name)
with r.gather(finishOnKey="#", method="POST", action=url, numDigits=1) as g:
g.say("Do you %d beds available? Press 1 for yes, and 0 for no." % call.bed_count)
return r
示例8: record
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def record(request):
"""A simple test view that returns a HttpResponse object."""
r = Response()
try:
u = request.POST["RecordingUrl"]
r.say("Thanks for the message... take a listen to your message .")
r.play(u)
r.say("Goodbye.")
r.redirect(reverse("calls_hello"))
return r
except Exception, ex:
logger.debug(ex)
r.redirect(reverse("calls_hello"))
示例9: play
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def play(request, url, loop=None):
"""See: twilio's website: http://www.twilio.com/docs/api/twiml/play.
Usage::
# urls.py
urlpatterns = patterns('',
# ...
url(r'^play/$', 'django_twilio.views.play', {
'url': 'http://blah.com/blah.wav',
}),
# ...
)
"""
r = Response()
r.play(url, loop=loop)
return r
示例10: notify_call
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def notify_call(request, notification_uuid):
r = Response()
try:
notification = Notification.objects.get(uuid=notification_uuid)
except Notification.DoesNotExist:
return r
r.say("This is an oncaller notification.")
message = notification.message
if message:
r.say(message, loop=2)
#duke!
r.play('http://dev.oncallr.com/static/audio/b2w.mp3')
r.pause(length=1)
r.say("Hit 1 to acknowledge, 2 to reject.", voice="woman")
r.gather(action="http://www.oncallr.com/notification/call/response/{0}/".format(notification_uuid), method="POST", numDigits=1, timeout=2, finishOnKey=None)
r.redirect(url="http://www.oncallr.com/notification/call/response/{0}/".format(notification_uuid), method="POST")
return r
示例11: twiml
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def twiml(self, tid, play=False):
"""Generate a TwiML, either to list tracks, or to play one"""
## Get JSON data to generate the TwiML
data = open("%s/%s.json" %(sap.twiml_path, tid), 'r').read()
json = loads(data)
## Twilio response
response = TwilioResponse()
## If we need to play the track, create a TwiML that just <Play>
if play:
## Correct digit, play + list when it's done
if int(play) <= len(json['tracks']):
response.play(json['tracks'][play]['preview'])
self.gather(response, json, tid)
## Else, list tracks again
else:
response.say("Sorry! Wrong digit, please try again.")
self.gather(response, json, tid)
## Otherwise, create a TwiML w/ <Gather> to get user input
else:
response.say("Hello! Here are a few tracks from %s" %(json['artist']))
self.gather(response, json, tid)
## Render Twilio response
return str(response)
示例12: handle_response
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def handle_response(request):
digits = request.POST.get('Digits', '')
twilio_response = Response()
#twilio_response.play('http://travellingscholar.com/ammi/firstmessage.mp3')
if digits == '2':
#digits3=request.POST.get('Digits','')
twilio_response.play('http://travellingscholar.com/ammi/message3b.mp3')
twilio_response.play('http://travellingscholar.com/ammi/message4.mp3')
req = 'http://23ee1813.ngrok.com/respond'
#r2 = gather_digits(req)
twilio_response.gather(action='respond2', numDigits=1)
#with twilio_response.gather(action='respond', numDigits=1) as g:
#twilio_response.pause(length=1)
#second_response= Response()
if digits == '1':
twilio_response.play('http://travellingscholar.com/ammi/message.mp3')
# number = request.POST.get('From', '')
# twilio_response.say('A text message is on its way')
# twilio_response.sms('You looking lovely today!', to=number)
return twilio_response
示例13: handle_second_response
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def handle_second_response(request):
digits = request.POST.get('Digits', '')
twilio_response_two=Response()
twilio_response_two.play('http://travellingscholar.com/ammi/message5a.mp3')
twilio_response_two.gather(action='respond3', numDigits=1)
return twilio_response_two
示例14: ring
# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import play [as 别名]
def ring(request):
r = Response()
r.play('http://bit.ly/phaltsw')
return r