diff --git a/setup.py b/setup.py index 46f494e..d7c175c 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup from setuptools import find_packages __author__ = 'Ryan McGrath ' -__version__ = '1.4.1' +__version__ = '1.4.2' setup( # Basic package information. diff --git a/twython/twython.py b/twython/twython.py index 7ce8973..2c3d232 100644 --- a/twython/twython.py +++ b/twython/twython.py @@ -9,8 +9,9 @@ """ __author__ = "Ryan McGrath " -__version__ = "1.4.1" +__version__ = "1.4.2" +import cgi import urllib import urllib2 import urlparse @@ -205,7 +206,10 @@ class Twython(object): if resp['status'] != '200': raise AuthError("Seems something couldn't be verified with your OAuth junk. Error: %s, Message: %s" % (resp['status'], content)) - request_tokens = dict(urlparse.parse_qsl(content)) + try: + request_tokens = dict(urlparse.parse_qsl(content)) + except: + request_tokens = dict(cgi.parse_qsl(content)) oauth_callback_confirmed = request_tokens.get('oauth_callback_confirmed')=='true' @@ -233,8 +237,11 @@ class Twython(object): Returns authorized tokens after they go through the auth_url phase. """ resp, content = self.client.request(self.access_token_url, "GET") - return dict(urlparse.parse_qsl(content)) - + try: + return dict(urlparse.parse_qsl(content)) + except: + return dict(cgi.parse_qsl(content)) + # ------------------------------------------------------------------------------------------------------------------------ # The following methods are all different in some manner or require special attention with regards to the Twitter API. # Because of this, we keep them separate from all the other endpoint definitions - ideally this should be change-able,