The error happens in your code. You shouldn't be using .encode()
here.
It is a bit counter-intuitive, but on_error()
will be called if on_success()
raised an exception, which is probably what happens here (a UnicodeDecodeError
). That's why you're seeing an error code 200 ("HTTP Ok").
Twython is returning data as unicode objects, so you can just do:
print(u"[%s](%s) - %s" % (data['created_at'], data['coordinates']['coordinates'], data['text']))
You should probably add your own try...except block in on_success()
for further debugging.
Also, I'm not sure what your tweetlog()
function does, but be aware if you are on Windows that print()
might have issues writing some codepoints as it will try to convert to the terminal's codepage.