This Question have 3 answers right now.

401 error using the Streaming features of Twitter API (through Tweepy)

By : Boa
Source: Stackoverflow.com
Question!

I've got an application which takes advantage of a number of features of the Twitter API. I've tested the application on one Windows 7 system, and all features worked well.

Testing the application on a second Windows 7 system, it seems that everything but the Public Stream and User Stream features is working (i.e. the app managed to authenticate, can follow/unfollow users, etc). On this system, the Stream features produce a 401 error. As I understand it, 401 could indicate an authorization error (which isn't happening in this case, since non-streaming features are available), or a difference in time configuration between Twitter's servers, and the client system.

I'd like the streaming features of my app to be available cross platform (Windows, Mac, Unix), and I can't expect end-users to tinker with their system's clock configurations. Can anyone recommend a system-agnostic Tweepy/python-based solution to the 401 error issue under the condition that it's caused by a time-configuration problem? Thanks.

EDIT:

On the system on which the Stream features were not working, after having manually tinkered with the system clock, with no success, I synchronized with time.windows.com. This didn't have any discernible effect on the time that was showing (I didn't have a view of the seconds), but it resolved the problem (i.e. the Twitter User and Public Stream features became available). The question remains - how does one prevent such an error from arising on end users' systems? It's unrealistic for me to warn users to adjust their clocks.

By : Boa


Answers
1
By : PryroTech


Your system clock is probably more than 5 minutes off.

By : Jonas


There is a way if the first element is the only one to start with that character:

$ a=(asd fgh ijk)
$ echo "${a[@]^[!${a:0:1}]}"
asd Fgh Ijk

This extracts the very first character of the first element, then excludes that character from being uppercased; [!${a:0:1}] expands to [!a], which matches only f and i as the first characters of their elements.

It fails if multiple elements start with the same character, though:

$ a=(asd agh ijk)
$ echo "${a[@]^[!${a:0:1}]}"
asd agh Ijk


Video about 401 error using the Streaming features of Twitter API (through Tweepy)