python 2.7 - Tweepy location on Twitter API filter always throws 406 error -


i'm using following code (from django management commands) listen twitter stream - i've used same code on seperate command track keywords - i've branched out use location, , (apparently rightly) wanted test out without disrupting existing analysis that's running.

i've followed docs , have made sure box in long/lat format (in fact, i'm using example long/lat twitter docs now). looks broadly same as question here, , tried using version of code answer - same error. if switch using 'track=...', same code works, it's problem location filter.

adding print debug inside streaming.py in tweepy can see what's happening, print out self.parameters self.url , self.headers _run, , get:

{'track': 't,w,i,t,t,e,r', 'delimited': 'length', 'locations': '-121.7500,36.8000,-122.7500,37.8000'}  

/1.1/statuses/filter.json?delimited=length , {'content-type': 'application/x-www-form-urlencoded'} respectively - seems me missing search location in way shape or form. don't believe i'm/i'm not 1 using tweepy location search, think it's more problem in use of bug in tweepy (i'm on 2.3.0), implementation looks right afaict.

my stream handling code here:

    consumer_key = 'stuff'     consumer_secret = 'stuff'     access_token='stuff'     access_token_secret_var='stuff'     import tweepy     import json      # listener, resposible receiving data     class stdoutlistener(tweepy.streamlistener):         def on_data(self, data):             # twitter returns data in json format - need decode first             decoded = json.loads(data)             #print type(decoded), decoded             # also, convert utf-8 ascii ignoring bad characters sent users             try:                 user, created = read_user(decoded)                 print "debug user", user, created                 if decoded['lang'] == 'en':                     tweet, created = read_tweet(decoded, user)                     print "debug tweet", tweet, created                 else:                     pass             except keyerror,e:                 print "error on key", e                 pass             except dataerror, e:                 print "dataerror", e                 pass              #print user, created              print ''             return true          def on_error(self, status):             print status        l = stdoutlistener()     auth = tweepy.oauthhandler(consumer_key, consumer_secret)     auth.set_access_token(access_token, access_token_secret_var)     stream = tweepy.stream(auth, l)     #locations must long, lat     stream.filter(locations=[-121.75,36.8,-122.75,37.8], track='twitter') 

the issue here order of coordinates.

correct format is: southwest corner(long, lat), northeast corner(long, lat). had them transposed. :(


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -