Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I handle Foursquare push POST requests using Flask?
    primarykey
    data
    text
    <p>I am trying all of the following methods to get the <a href="https://developer.foursquare.com/overview/realtime" rel="nofollow">push request</a> information and they are all failing:</p> <pre><code>@app.route('/handlepush', methods=['POST']) def handlepush(): """ Handles push notifications from Foursquare """ print 'handling push' print request try: print 'request.form:' + json.loads(request.form['checkin'], parse_float=str) except: print 'request.form error' try: print 'request.data: ' + json.loads(request.data['checkin'], parse_float=str) except: print 'no request.data' try: print 'request.form' + request.form except: print 'no request.form' try: print 'request.args' + request.args except: print 'no request.args' if request.headers['Content-Type'] == 'text/plain': print'text/plain' return "Text Message: " + request.data elif request.headers['Content-Type'] == 'application/json': print 'application/json' return "JSON Message: " + json.dumps(request.json) try: print 'request.form["id"]:' + request.form['checkin']['id'] except: print 'request.form error' try: print request.data['checkin']['id'] except: print 'request.data error' try: print 'request.json: ' + request.json except: print 'no request.json' return 'hi' </code></pre> <p>and this is my response:</p> <pre><code>2013-01-28T00:54:31+00:00 app[web.1]: &lt;Request 'http://my.herokuapp.com/handlepush' [POST]&gt; 2013-01-28T00:54:31+00:00 app[web.1]: handling push 2013-01-28T00:54:31+00:00 app[web.1]: no request.args 2013-01-28T00:54:31+00:00 app[web.1]: 10.71.26.114 - - [28/Jan/2013 00:54:31] "POST /handlepush HTTP/1.1" 200 - 2013-01-28T00:54:31+00:00 app[web.1]: request.form error 2013-01-28T00:54:31+00:00 app[web.1]: no request.data 2013-01-28T00:54:31+00:00 app[web.1]: no request.form 2013-01-28T00:54:31+00:00 app[web.1]: request.data error 2013-01-28T00:54:31+00:00 app[web.1]: no request.json 2013-01-28T00:54:31+00:00 app[web.1]: request.form error </code></pre> <p>So I was wondering the best way to approach this. request.json works for json POSTs in my experience when the header is specified as 'application/json', but I don't know how to get this push data.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload