• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python twiml.Response类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twilio.twiml.Response的典型用法代码示例。如果您正苦于以下问题:Python Response类的具体用法?Python Response怎么用?Python Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: voice

def voice(request):
    """Create a Twilio response object which gathers the callers input"""
    r = Response()
    with r.gather(action='/respond/') as g:
        g.say('Please enter a number to play phone buzz. Press the pound key when finished.', voice='woman')
        g.pause(length=10)
    return r
开发者ID:jtmurphy89,项目名称:phonebuzz,代码行数:7,代码来源:views.py


示例2: handle_twilio_request

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)
开发者ID:BartKrol,项目名称:autodialer,代码行数:26,代码来源:views.py


示例3: sms_personal

def sms_personal(request):
    name = request.POST.get('Body', '')
    msg = 'Hey %s, how are you today?' % (name)
    
    r = Response()
    r.message(msg)
    return r
开发者ID:JPranjali,项目名称:twilio-django-part-1,代码行数:7,代码来源:views.py


示例4: testAddNumberConvenienceStatusCallbackEvent

 def testAddNumberConvenienceStatusCallbackEvent(self):
     """ add a number to a dial, convience method """
     r = Response()
     d = r.addDial()
     d.addNumber("1231231234", statusCallback="http://example.com", statusCallbackEvent="initiated completed")
     r = self.strip(r)
     assert_equal(r, '<?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number statusCallback="http://example.com" statusCallbackEvent="initiated completed">1231231234</Number></Dial></Response>')
开发者ID:Adomako-Bismark,项目名称:twilio-python,代码行数:7,代码来源:test_twiml.py


示例5: sms_handler

def sms_handler(request):
	r = Response()
	body = request.POST["Body"]
	print body
	penalty_message = get_penalty_message(body)
	r.sms(penalty_message)
	return r
开发者ID:jnishiyama,项目名称:Trollo,代码行数:7,代码来源:views.py


示例6: conference

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
开发者ID:BantouTelecom,项目名称:django-twilio,代码行数:26,代码来源:views.py


示例7: do_simplehelp

    def do_simplehelp():

        data = parse_form(request.form)
        url = "{}/handle?{}".format(request.base_url, urlencode(data, True))

        r = Response()
        r.say('System is down for maintenance')
        fallback_url = echo_twimlet(r.toxml())

        try:
            client = twilio()
            client.phone_numbers.update(
                request.form['twilio_number'],
                friendly_name='[RRKit] Simple Help Line',
                voice_url=url,
                voice_method='GET',
                voice_fallback_url=fallback_url,
                voice_fallback_method='GET'
            )

            flash('Help menu configured', 'success')
        except Exception as e:
            print(e)
            flash('Error configuring help menu', 'danger')

        return redirect('/simplehelp')
开发者ID:Twilio-org,项目名称:rapid-response-kit,代码行数:26,代码来源:simplehelp.py


示例8: receive

def receive(request):
    logger.debug('Get params: {0}'.format(request.GET))
    logger.debug('Post params: {0}'.format(request.POST))

#    {
#     u'Body': [u'Helo toto'],
#     u'FromZip': [u''],
#     u'SmsStatus': [u'received'],
#     u'FromCountry': [u'CA'],
#     u'FromCity': [u'MONTREAL'],
#     u'ApiVersion': [u'2010-04-01'],
#     u'To': [u'+15144180546'],
#     u'From': [u'+15146258937'],
#     u'ToZip': [u''],
#     u'ToCountry': [u'CA'],
#     u'ToState': [u'QC'],
#     u'AccountSid': [u'AC791403f3ec0098401e629d6aaf6b44bd'],
#     u'SmsSid': [u'SMb928abbc11c19f6e9f5215ec15e151c8'],
#     u'ToCity': [u'MONTREAL'],
#     u'FromState': [u'QC'],
#     u'SmsMessageSid': [u'SMb928abbc11c19f6e9f5215ec15e151c8']
#    }

    from_number = request.POST.get('From', None)
    if from_number in callers:
        r = Response()
        r.sms('Voici ton message, peanut! ({0})'.format(request.POST.get('Body', '')))
        return r
    else:
        return HttpResponseNotFound('Could not find your stuff')
开发者ID:yorrick,项目名称:home-automation,代码行数:30,代码来源:views.py


示例9: handle_selection

def handle_selection(request, slug):

    voicemailbox = get_object_or_404(VoicemailBox, slug=slug)

    chunk = voicemailbox.work.chunk_set.filter(number=request.POST.get('Digits'))

    if chunk.chunksubmission:


    r = Response()
    r.say(
        "Thank you. "
        "Please start reading, "
        "when you are done, you can hang up. "
    )
    
    action = reverse('handle-recording', kwargs={'slug': slug})

    r.record(action=action, timeout=20, maxLength=360, playBeep=True)


@csrf_exempt
def handle_recording(request, slug=None):

    voicemailbox = get_object_or_404(VoicemailBox, slug=slug)

    voicemailbox.collection.add_voicemail(
        audio_url=request.POST.get('RecordingUrl'),
        title='recorded in %s for %s' % (location, voicemailbox.target_location),
        location=voicemailbox.target_location,
    )
    return HttpResponse()
开发者ID:orzubalsky,项目名称:invisible,代码行数:32,代码来源:views.py


示例10: giveHelp

def giveHelp(person_one, request):
    """ Method for ending a conversation """
    help_message = ""
    help_message += "End conversation: %s Unsubscribe: %s Help: %s" % (end_command, unsubscribe_command, help_command)
    r = Response()
    r.message(msg=help_message, to=person_one.phone_number)
    return r
开发者ID:codekansas,项目名称:phonely,代码行数:7,代码来源:views.py


示例11: get

    def get(self, request, client_call, pks):
        pks = pks.split(",")
        try:
            shelter = Shelter.objects.get(pk=pks[0])
        except Shelter.DoesNotExist:
            pks = ",".join(pks[1:])
            if pks:
                return redirect(reverse("phone:start_shelter_call", kwargs={"pks": pks, "client_call": client_call}))

        site = Site.objects.get_current()
        client.calls.create(
            to=shelter.phone_number,
            from_=settings.TWILIO_CALLER_ID,
            url=urljoin(
                "http://" + site.domain,
                reverse("phone:verify_shelter_availability", kwargs={"client_call": client_call, "pk": pks[0]}),
            ),
            method="GET",
            status_callback="http://%s/phone/shelter_call_callback/%s/%s/"
            % (site.domain, client_call, ",".join(pks[1:])),
            status_method="GET",
        )

        r = Response()
        r.say("We are contacting %s. Please hold." % shelter.name)
        r.enqueue(name="waiting_for_shelter", wait_url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient")
        return r
开发者ID:pombredanne,项目名称:continuum,代码行数:27,代码来源:views.py


示例12: handle_replay_message

def handle_replay_message(request):
    digits = request.GET['digits']
    msg = get_fizzbuzz_message(int(digits))

    twilio_response = Response()
    twilio_response.say(msg)
    return twilio_response
开发者ID:Sticksword,项目名称:exploringTwilioAPI,代码行数:7,代码来源:views.py


示例13: sms

def sms(request):
    body = request.POST.get("Body", "")
    reg = RegistroSMS.objects.get(pk=body)
    msg = "Hola %s, que tal %s" % (reg.comprador.first_name, reg.vendedor.username)
    r = Response()
    r.sms(msg)
    return r
开发者ID:bartulo,项目名称:tiempotietar,代码行数:7,代码来源:views.py


示例14: do_ringdown

    def do_ringdown():
        numbers = parse_numbers(request.form.get('numbers', ''))
        data = {
            'stack': numbers,
            'sorry': request.form.get('sorry', '')
        }

        url = "{}/handle?{}".format(request.base_url, urlencode(data, True))

        r = Response()
        r.say('System is down for maintenance')
        fallback_url = echo_twimlet(r.toxml())

        try:
            client = twilio()
            client.phone_numbers.update(request.form['twilio_number'],
                                        friendly_name='[RRKit] Ringdown',
                                        voice_url=url,
                                        voice_method='GET',
                                        voice_fallback_url=fallback_url,
                                        voice_fallback_method='GET')

            flash('Number configured', 'success')
        except Exception:
            flash('Error configuring number', 'danger')

        return redirect('/ringdown')
开发者ID:Twilio-org,项目名称:rapid-response-kit,代码行数:27,代码来源:ringdown.py


示例15: verify_sms

def verify_sms(request):
    from_number = request.POST.get("From", None)
    from_text = request.POST.get("Body", None)
    msg = game_logic(from_number, from_text)
    r = Response()
    r.message(msg)
    return r
开发者ID:peasnrice,项目名称:Point2Point,代码行数:7,代码来源:web_views.py


示例16: sms

def sms(request):
    name = request.POST.get('Body', '')
    msg = 'Hey %s'

    r = Response()
    r.message(msg)
    return r
开发者ID:michaelperret,项目名称:GroupText,代码行数:7,代码来源:views.py


示例17: handle_third_response

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
开发者ID:Sabina321,项目名称:ammitips_code,代码行数:7,代码来源:views.py


示例18: handle_noticeboard_inbound

    def handle_noticeboard_inbound():

        pusher_key = app.config.get('PUSHER_KEY', None)
        pusher_secret = app.config.get('PUSHER_SECRET', None)
        pusher_app_id = app.config.get('PUSHER_APP_ID', None)

        try:
            p = Pusher(pusher_app_id, pusher_key, pusher_secret)

            p['rrk_noticeboard_live'].trigger(
                'new_message',
                {
                    'image': request.values.get('MediaUrl0', None),
                    'body': request.values.get('Body', None),
                    'from': request.values.get('From', None)
                }
            )
        except:
            return '<Response />'

        to = request.values.get('To', '')
        r = Response()
        r.message(
            '''Thank you, your image has been posted
            to {0}noticeboard/live/{1}'''.format(request.url_root, to))
        return r.toxml()
开发者ID:Twilio-org,项目名称:rapid-response-kit,代码行数:26,代码来源:noticeboard.py


示例19: get_sms_score

def get_sms_score(request):
    r = Response()
    return_number = request.POST['From']
    print return_number
    try:
        team_id = request.POST['Body']
        team = Team.objects.get(pk=team_id)
        scores = Score.objects.filter(team=team)
        sms_string = "Team:"+team.name +"\n"
        

     
        for score in scores:
            sms_string = sms_string + "Event: " +score.event.name+ " Score:"+str(score.score)+"\n"
      
    except Team.DoesNotExist:    
        sms_string = "We're sorry, The team number entered does not exist."
       
    except ValueError:
        sms_string= "Invalid Team Number"  
    
    
    r.sms(sms_string) 
         
    return r
开发者ID:hgrimberg01,项目名称:esc,代码行数:25,代码来源:views.py


示例20: phone_vote

def phone_vote(request):
    body = request.POST.get('Body', None)
    from_number = request.POST.get('From', None)
    r = Response()
    message = ''
    if body and body.isdigit():
        choice_id = int(body)
        choice = Choice.objects.filter(id=choice_id)
        if choice:
            c = choice[0]
            vc = VoterChoice.objects.filter(choice__poll=c.poll, phone_number=from_number)
            if vc:
                message = 'Sorry, you have already voted in this poll.' \
                    + ' You cannot vote twice.'
            elif c.poll.status() == 'ONGOING':
                c.votes += 1
                c.save()
                vc_obj = VoterChoice(choice=c, phone_number=from_number)
                vc_obj.save()
                message = 'Thanks for your vote!'
            elif c.poll.status() == 'PENDING':
                message = 'Sorry, your vote is invalid.' \
                    + ' This poll has not yet begun.'
            else:
                message = 'Sorry, your vote is invalid.' \
                    + ' This poll has already finished.'

    if not message:
        message = 'Please text a vote number correctly to vote.'
    r.sms(message)
    return r
开发者ID:keiko713,项目名称:twilio_app,代码行数:31,代码来源:views.py



注:本文中的twilio.twiml.Response类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python voice_response.VoiceResponse类代码示例发布时间:2022-05-27
下一篇:
Python util.transform_params函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap