Skip to content
HU, Pili edited this page Jul 1, 2013 · 4 revisions

SNSAPI Troubleshooting

If you have any problem, don't hesitate to file an issue or ask in our Google group.

When you ask, it's appreciated if you can describe your environment and attach some logs. Since "[DEBUG]" entries contain some user information, please do grep -vi debug before you paste at any public page.

Followings are some known problems.

Encoding

The encoding of SNSAPI:

  • All files in utf-8 encoding.
  • SNSAPI use utf-8 for I/O by default (e.g. read/write the console).
  • SNSAPI use unicode internally.

Some non-English version of windows have problem running SNSAPI. One way is to change the config of default encoding in snsapi/snsconf.py: change SNSAPI_CONSOLE_STDOUT_ENCODING = 'utf-8' to SNSAPI_CONSOLE_STDOUT_ENCODING = 'gbk' (e.g. your OS uses 'gbk').

"_http_get fail: [Errno socket error] [Errno 8] _ssl.c:504: EOF occurred in violation of protocol"

This is the network problem under SNSAPI. We can only catch it and protect SNSAPI from crash. It's suspected to have something to do with GFW. The author also suffer from platform failure from time to time. There is little to do about it. Maybe:

  • Use a public proxy: e.g. http://proxy-list.org.
  • Buy a VPS.
  • Other wall climbing techniques, e.g. Tor, GoAgent, etc.

Detailed flow is followed: (with user secrets masked)

[DEBUG][20130131-212124][snsbase.py][get_saved_token][263]No access token saved, try to get one through sns.auth() :D
[INFO][20130131-212124][snsbase.py][oauth2][189]Try to authenticate 'sina_account_1' using OAuth2
https://api.weibo.com/oauth2/authorize?redirect_uri=xxxxx&client_id=xxxxx&display=json
Please input the whole url from Broswer's address bar:
http://www.baidu.com/?code=xxxxx
[DEBUG][20130131-212139][snsbase.py][_oauth2_second][170]get url: http://www.baidu.com/?code=xxxxx
[DEBUG][20130131-212139][oauth.py][_http_post][104]POST https://api.weibo.com/oauth2/access_token
[DEBUG][20130131-212141][snsbase.py][_oauth2_second][175]Authorized! access token is {xxxxx}
[INFO][20130131-212141][snsbase.py][_oauth2_second][176]Channel 'sina_account_1' is authorized
>>> print ht(1)
[WARNING][20130131-212145][snsbase.py][_http_get][375]_http_get fail: [Errno socket error] [Errno 8] _ssl.c:504: EOF occurred in violation of protocol
[WARNING][20130131-212145][sina.py][home_timeline][154]Catch exception: 'statuses'
[INFO][20130131-212145][snspocket.py][home_timeline][272]Read 0 statuses

[WARNING][20130116-124918][snsbase.py][_oauth2_second][178]Auth second fail. Catch exception: HTTP Error 401: Unauthorized

There are many causes of this problem. See this issue for some discussions.

Some possibilities:

  • Your app_key and/or app_secret are missing/incorrect. Note, you may have pasted correct keys there but used wrong field name. They must be exactly named as app_key and app_secret. No blanks in the field name.