当前位置: 首页>>代码示例>>Python>>正文


Python Response.sms方法代码示例

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


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

示例1: handle_response_digits

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [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
开发者ID:kishan,项目名称:Django_Twilio_Project,代码行数:35,代码来源:views.py

示例2: sms_handler

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
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,代码行数:9,代码来源:views.py

示例3: phone_vote

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
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,代码行数:33,代码来源:views.py

示例4: receive

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
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,代码行数:32,代码来源:views.py

示例5: get_sms_score

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
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,代码行数:27,代码来源:views.py

示例6: sms

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
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,代码行数:9,代码来源:views.py

示例7: handle_survey

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
    def handle_survey():
        body = request.args['Body']
        normalized = body.strip().lower()
        survey_id = request.args['survey']
        phone_number = request.args['From']

        json_url = '{firebase_url}/survey/{survey_id}/phone_number/{phone_number}.json'.format(
            firebase_url=app.config['FIREBASE_URL'],
            survey_id=survey_id,
            phone_number=phone_number)

        result = requests.get(json_url, params={'auth': app.config['FIREBASE_SECRET']}).json()
        if result:
            resp = Response()
            resp.sms('Your response has been recorded')
            return str(resp)

        normalized = normalized if normalized in ['yes', 'no'] else 'N/A'
        requests.post(json_url, params={'auth': app.config['FIREBASE_SECRET']}, json={
            'raw': body,
            'normalized': normalized,
            'number': request.args['From'],
            'survey_id': request.args['survey']
        })

        resp = Response()
        resp.sms('Thanks for answering our survey')
        return str(resp)
开发者ID:Twilio-org,项目名称:rapid-response-kit,代码行数:30,代码来源:survey.py

示例8: coming_up

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
def coming_up(request):
    sessions = Session.objects.filter(is_public=True, event=Event.objects.current())
    r = Response()
    inmsg = request.POST.get('Body').strip() or 'next'
    if inmsg.lower() == 'next':
        messages = _as_sms(Session.objects.next())
    elif inmsg.lower() == 'now':
        messages = _as_sms(Session.objects.current())
    elif inmsg.lower() == 'lunch':
        try:
            now = timezone.now()
            messages = _as_sms(Session.objects.filter(start_time__day=now.day,
                                                      start_time__month=now.month,
                                                      start_time__year=now.year,
                                                      title__icontains='lunch')[0])
        except IndexError:
            messages = ["No lunch on the schedule for today, sorry.\n"]
    else:
        try:
            ts = dateparse(inmsg)
            if ts.hour is 0 and ts.minute is 0:
                messages = ["A lot of stuff can happen in a whole day! Try specifying a time.\n"]
            else:
                messages = _as_sms(sessions.filter(start_time__lte=ts, end_time__gte=ts))
        except:
            messages = ["Welcome to TCamp!\n\nOptions:\nnow: Current sessions\nnext: Next timeslot\nlunch: When's lunch?\n<time>, eg. 4:30pm: What's happening at 4:30?\n"]

    l = len(messages)
    for i, message in enumerate(messages):
        r.sms(message + '\n(%d/%d)' % (i+1, l))
    return r
开发者ID:andergmartins,项目名称:tcamp,代码行数:33,代码来源:views.py

示例9: handle_fourth_response

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [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
开发者ID:Sabina321,项目名称:ammitips_code,代码行数:10,代码来源:views.py

示例10: reply_list

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
    def reply_list(self, msgs):
        """Simple wrapper for returning a text message response given a list of texts to return"""
        r = Response()
        callback_url = self.request.build_absolute_uri(reverse('sms-callback'))
        #print(callback)
        #print(msgs)
        for p in msgs:
            r.sms(p, statusCallback=callback_url)

        return r
开发者ID:jbranigan,项目名称:chicago-early-learning,代码行数:12,代码来源:sms.py

示例11: reply_to_sms_message

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
def reply_to_sms_message(request):
    text = request.REQUEST['Body']
    mtd = CumtdApi(os.environ['CUMTD_API_KEY'])
    stops = mtd.get_stops_by_search(text)
    buses = mtd.get_departures_by_stop(stops['stops'][0]['stop_id'])
    r = Response()
    response_text = 'Departures at ' + stops['stops'][0]['stop_name'] + '\n'
    for trip in buses['departures']:
        response_text += trip['headsign'] + ' in ' + str(trip['expected_mins']) + ' mins\n'
    r.sms(response_text[:159])
    return r
开发者ID:sunahsuh,项目名称:mtd_sms,代码行数:13,代码来源:views.py

示例12: handle_response

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [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
    
开发者ID:Quantumke,项目名称:InteractiveVoiceResponseSystem,代码行数:13,代码来源:views.py

示例13: reply_to_sms

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
def reply_to_sms(request):
    response = Response()

    user, created = PhoneUser.objects.get_or_create(number=request.POST['From'])
    print(user)
    message = IncomingMessage()
    message.content = request.POST['Body']
    message.sender = user
    message.save()

    response.sms('Thank you for your feedback!')
    return response
开发者ID:RHoKSoton,项目名称:jipange,代码行数:14,代码来源:views.py

示例14: status

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
def status(request):
    logger.debug('Get params: {0}'.format(request.GET))
    logger.debug('Post params: {0}'.format(request.POST))

    from_number = request.POST.get('From', None)

    if not settings.DEBUG and from_number not in callers:
        return HttpResponseNotFound('Could not find your stuff')

    logger.debug('getting motion status')
    status = get_motion_status()
    logger.debug('got motion status: {0}'.format(status))
    r = Response()
    r.sms('Status for motion: {0}'.format(status))
    return r
开发者ID:yorrick,项目名称:home-automation,代码行数:17,代码来源:views.py

示例15: reply_to_sms_messages

# 需要导入模块: from twilio.twiml import Response [as 别名]
# 或者: from twilio.twiml.Response import sms [as 别名]
def reply_to_sms_messages(request):
    
    requestQueryDict = request.POST.copy()

    try:
        incomingPhoneNumber = requestQueryDict['From'].replace('%2B', '')
        incomingText = requestQueryDict['Body']

        orders = models.ShirtRequest.objects(phoneNumber=incomingPhoneNumber)

        if orders.count() > 0:

            if incomingText in constants.YES_NO_ARRAY:

                msg = constants.SUCCESS_MESSAGE_CANCELLATION
                
                if incomingText in constants.YES_ARRAY:
                    artWorkURL = str(orders.first()['shirtPicturePath'])
                    requestMapping = helper.returnOrderMappings(artWorkURL)

                    getResponse = helper.makeRequest('POST', 'https://www.shirts.io/api/v1/order/', 
                        requestMapping)

                    msg = helper.returnText(getResponse.json())

                orders.delete()
            else:
                msg = constants.ERROR_MESSAGE_ALREADY_HAVE_SHIRT_REQUEST
        else:
            picturePath = helper.generateShirtImage(incomingPhoneNumber, 
                                                    incomingText)

            pictureLink = constants.APPLICATION_IMAGE_LINK + incomingPhoneNumber + ".png"
            newOrder = models.ShirtRequest(phoneNumber = incomingPhoneNumber)
            newOrder.shirtMessage = incomingText
            newOrder.shirtPicturePath = pictureLink
            newOrder.save()

            msg = helper.generateVerification(pictureLink)
    except Exception as e:
        msg = constants.ERROR_MESSAGE_SERVER 

    r = Response()
    r.sms(msg)
    return r
    
开发者ID:alioral,项目名称:ShirtsIOSMS,代码行数:47,代码来源:views.py


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