コード例 #1
0
def speak():
    signature = request.headers.get('X-Plivo-Signature')
    uri = url_for('speak', _external=True)
    auth_token = "Your AUTH TOKEN"
    url = request.url
    parsed = urlparse.urlparse(url)
    params = dict(urlparse.parse_qsl(parsed.query))
    
    data = dict((key, request.form.getlist(key)[0]) for key in request.form.keys())
    params.update(data)
    valid = plivo.validate_signature(uri,params,signature,auth_token)
    print valid

    # Sender's phone numer
    from_number = request.values.get('From')

    # Receiver's phone number - Plivo number
    to_number = request.values.get('To')

    # The text which was received
    text = request.values.get('Text')

    # Print the message
    print 'Text received: %s - From: %s' % (text, from_number)
    return "Text received"
コード例 #2
0
def speak():
    signature = request.headers.get('X-Plivo-Signature')
    uri = url_for('speak', _external=True)
    auth_token = "Your AUTH TOKEN"
    url = request.url
    parsed = urlparse.urlparse(url)
    params = dict(urlparse.parse_qsl(parsed.query))

    data = dict(
        (key, request.form.getlist(key)[0]) for key in request.form.keys())
    params.update(data)
    valid = plivo.validate_signature(uri, params, signature, auth_token)
    print valid

    # Sender's phone numer
    from_number = request.values.get('From')

    # Receiver's phone number - Plivo number
    to_number = request.values.get('To')

    # The text which was received
    text = request.values.get('Text')

    # Print the message
    print 'Text received: %s - From: %s' % (text, from_number)
    return "Text received"
コード例 #3
0
def speak():
    signature = request.headers.get('X-Plivo-Signature')
    uri = url_for('speak', _external=True)
    auth_token = "Your AUTH TOKEN"
    url = request.url
    parsed = urlparse.urlparse(url)
    params = dict(urlparse.parse_qsl(parsed.query))
    
    data = dict((key, request.form.getlist(key)[0]) for key in request.form.keys())
    params.update(data)
    valid = plivo.validate_signature(uri,params,signature,auth_token)
    print valid

    r = plivoxml.Response()
    speak_params = {
        'loop': '3'
    }
    r.addSpeak("Hello, from Plivo",**speak_params)
    response = make_response(r.to_xml())
    response.headers["Content-type"] = "text/xml"
    print r.to_xml()
    return response