Пример #1
0
    def test_action_method(self):
        """ Test the action and method parameters on Sms """
        r = VoiceResponse()
        r.sms('Hello', method='POST', action='example.com?id=34&action=hey')

        assert_equal(
            self.strip(r),
            '<?xml version="1.0" encoding="UTF-8"?><Response><Sms action="example.com?id=34&amp;action=hey" method="POST">Hello</Sms></Response>'
        )
Пример #2
0
    def test_body(self):
        """ Test hello world """
        r = VoiceResponse()
        r.sms('Hello, World')

        assert_equal(
            self.strip(r),
            '<?xml version="1.0" encoding="UTF-8"?><Response><Sms>Hello, World</Sms></Response>'
        )
Пример #3
0
    def test_empty(self):
        """ Test empty sms verb """
        r = VoiceResponse()
        r.sms('')

        assert_equal(
            self.strip(r),
            '<?xml version="1.0" encoding="UTF-8"?><Response><Sms /></Response>'
        )
Пример #4
0
    def test_response(self):
        r = VoiceResponse()
        r.hangup()
        r.leave()
        r.sms('twilio sms', to='+11234567890', from_='+10987654321')

        assert_equal(
            self.strip(r),
            '<?xml version="1.0" encoding="UTF-8"?><Response><Hangup /><Leave /><Sms from="+10987654321" to="+11234567890">twilio sms</Sms></Response>'
        )
Пример #5
0
def voice():
    """Respond to incoming phone calls with a text message."""
    # Start our TwiML response
    resp = VoiceResponse()

    # Read a message aloud to the caller
    resp.say("Hello! You will get an SMS message soon.")

    # Also tell Twilio to send a text message to the caller
    resp.sms("This is the ship that made the Kessel Run in fourteen parsecs?")

    return str(resp)
Пример #6
0
    def test_to_from_action(self):
        """ Test the to, from, and status callback """
        r = VoiceResponse()
        r.sms('Hello, World',
              to=1231231234,
              from_=3453453456,
              status_callback='example.com?id=34&action=hey')

        assert_equal(
            self.strip(r),
            '<?xml version="1.0" encoding="UTF-8"?><Response><Sms from="3453453456" statusCallback="example.com?id=34&amp;action=hey" to="1231231234">Hello, World</Sms></Response>'
        )
Пример #7
0
def handle_response(request):

    digits=request.POST.get('Digits', '')

    twilio_response=VoiceResponse()

    if digits=='1':
        twilio_response.play('http://bit.ly/phaltsw')

    if digits == '2':
        number.request.POST.get('From','')
        twilio_response.say('Text Message')
        twilio_response.sms('Issue',to=number)

    return twilio_response
Пример #8
0
def handle_user_response(request):
    """ response handler function"""

    # twilio passes key pressed digits via form-data form key value Digits
    digits = request.POST.get('Digits', '')
    response = VoiceResponse()

    # evaluate user input from phones keypad and take an appropriate action
    if digits == '1':
        response.play('http://demo.twilio.com/hellomonkey/monkey.mp3')
    if digits == '2':
        number = request.POST.get('From', '')
        response.say('Thank you for calling, for more content see site blog')
        response.sms(
            'Thanks for trying out this tutorial, share with your friends!',
            to=number)

    # HttResponse will return xml response object for twilio api to process
    return HttpResponse(str(response), content_type='application/xml')
Пример #9
0
from twilio.twiml.voice_response import VoiceResponse, Say, Sms

response = VoiceResponse()
response.say('Our store is located at 123 Easy St.')
response.sms(
    'Store Location: 123 Easy St.', action='/smsHandler.php', method='POST'
)

print(response)
Пример #10
0
from twilio.twiml.voice_response import VoiceResponse, Say, Sms

response = VoiceResponse()
response.say('Our store is located at 123 Easy St.')
response.sms('Store Location: 123 Easy St.',
             action='/smsHandler.php',
             method='POST')

print(response)
Пример #11
0
from twilio.twiml.voice_response import VoiceResponse, Sms

response = VoiceResponse()
response.sms(
    'The king stay the king.', to='+14105556789', from_='+14105551234'
)

print(response)
Пример #12
0
from twilio.twiml.voice_response import VoiceResponse, Sms

response = VoiceResponse()
response.sms('The king stay the king.',
             to='+14105556789',
             from_='+14105551234')

print(response)
Пример #13
0
from twilio.twiml.voice_response import VoiceResponse, Say, Sms

response = VoiceResponse()
response.say('Our store is located at 123 Easy St.')
response.sms('Store Location: 123 Easy St.')

print(response)
Пример #14
0
from twilio.twiml.voice_response import VoiceResponse, Say, Sms

response = VoiceResponse()
response.say('Our store is located at 123 Easy St.')
response.sms('Store Location: 123 Easy St.', status_callback='/smsHandler.php')

print(response)