Skip to content

Example code of handling and parsing a Pollfish Server 2 Server (S2S) or webhook callback, using Flask.

License

Notifications You must be signed in to change notification settings

LoopsGod/pollfish-callback-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pollfish S2S Callbacks

Example code for handling and parsing a Pollfish Server 2 Server (S2S) or webhook callback, using Flask.

Pollfish Docs: https://www.pollfish.com/docs/s2s

Setting up

In order to get set up, you are going to need to clone this repository. After that, set up a virtualenv and satisfy the requirements by running pip install -r requirements.txt. (please make sure you're in the root directory when you run pip install). Additional explanation can be found on the Flask quickstart and documentation.

Code samples

Find some code samples below.

Routing & handling

Include handler function.

# Include the handler function(s)
from handlers.pollfish_handler import verify

Setup routing.

@app.route('/webhooks/pollfish-s2s')
def verify_survey():
    return verify()

Query strings in handler function

Get the arguments from the Pollfish request query strings. You should have defined those in your application / dashboard.

Flask has an easy function for getting and parsing query strings: request.args.get()

from flask import request

def verify():
    device_id = request.args.get('device_id')
    cpa = request.args.get('cpa')
    request_uuid = request.args.get('request_uuid')
    timestamp = request.args.get('timestamp')
    tx_id = request.args.get('tx_id')

For the complete code, check the files : )

About

Example code of handling and parsing a Pollfish Server 2 Server (S2S) or webhook callback, using Flask.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages