From 7d1ffefc45a7f29877034c0fe2a95ab00a26d5ac Mon Sep 17 00:00:00 2001 From: Mike Helmick Date: Thu, 4 Apr 2013 14:44:05 -0400 Subject: [PATCH 1/3] Fixes #158, #159, #160 --- twython/twython.py | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/twython/twython.py b/twython/twython.py index 93c5c42..09b2783 100644 --- a/twython/twython.py +++ b/twython/twython.py @@ -99,7 +99,6 @@ class Twython(object): self.api_url = 'https://api.twitter.com/%s' self.request_token_url = self.api_url % 'oauth/request_token' self.access_token_url = self.api_url % 'oauth/access_token' - self.authorize_url = self.api_url % 'oauth/authorize' self.authenticate_url = self.api_url % 'oauth/authenticate' # Enforce unicode on keys and secrets @@ -265,8 +264,11 @@ class Twython(object): return self._last_call['headers'][header] return self._last_call - def get_authentication_tokens(self): + def get_authentication_tokens(self, force_login=False, screen_name=''): """Returns an authorization URL for a user to hit. + + :param force_login: (optional) Forces the user to enter their credentials to ensure the correct users account is authorized. + :param app_secret: (optional) If forced_login is set OR user is not currently logged in, Prefills the username input box of the OAuth login screen with the given value """ request_args = {} if self.callback_url: @@ -287,6 +289,12 @@ class Twython(object): 'oauth_token': request_tokens['oauth_token'], } + if force_login: + auth_url_params.update({ + 'force_login': force_login, + 'screen_name': screen_name + }) + # Use old-style callback argument if server didn't accept new-style if self.callback_url and not oauth_callback_confirmed: auth_url_params['oauth_callback'] = self.callback_url @@ -453,28 +461,12 @@ class Twython(object): ########################################################################### def getProfileImageUrl(self, username, size='normal', version='1'): - """Gets the URL for the user's profile image. - - :param username: (required) Username, self explanatory. - :param size: (optional) Default 'normal' (48px by 48px) - bigger - 73px by 73px - mini - 24px by 24px - original - undefined, be careful -- images may be - large in bytes and/or size. - :param version: (optional) A number, default 1 because that's the - only API version for Twitter that supports this call - """ - endpoint = 'users/profile_image/%s' % username - url = self.api_url % version + '/' + endpoint - - response = self.client.get(url, params={'size': size}, allow_redirects=False) - image_url = response.headers.get('location') - - if response.status_code in (301, 302, 303, 307) and image_url is not None: - return image_url - else: - raise TwythonError('getProfileImageUrl() threw an error.', - error_code=response.status_code) + warnings.warn( + "This function has been deprecated. Twitter API v1.1 will not have a dedicated endpoint \ + for this functionality.", + DeprecationWarning, + stacklevel=2 + ) @staticmethod def stream(data, callback): From fffedd4588a73c85032c09227af6c6e2ca5857c7 Mon Sep 17 00:00:00 2001 From: Mike Helmick Date: Thu, 4 Apr 2013 14:52:32 -0400 Subject: [PATCH 2/3] Version bump --- setup.py | 2 +- twython/twython.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e6d49c9..a6bf312 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup from setuptools import find_packages __author__ = 'Ryan McGrath ' -__version__ = '2.6.1' +__version__ = '2.7.0' setup( # Basic package information. diff --git a/twython/twython.py b/twython/twython.py index 09b2783..cddf739 100644 --- a/twython/twython.py +++ b/twython/twython.py @@ -7,7 +7,7 @@ """ __author__ = "Ryan McGrath " -__version__ = "2.6.1" +__version__ = "2.7.0" import urllib import re From e65790d7170c97c120dd6037102358c276907f45 Mon Sep 17 00:00:00 2001 From: Mike Helmick Date: Thu, 4 Apr 2013 14:52:54 -0400 Subject: [PATCH 3/3] New showOwnedLists method Returns the lists owned by the specified Twitter user. Private lists will only be shown if the authenticated user is also the owner of the lists. --- twython/twitter_endpoints.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/twython/twitter_endpoints.py b/twython/twitter_endpoints.py index 5f79e66..ff78779 100644 --- a/twython/twitter_endpoints.py +++ b/twython/twitter_endpoints.py @@ -320,6 +320,10 @@ api_table = { 'url': '/lists/members/destroy_all.json', 'method': 'POST' }, + 'showOwnedLists': { + 'url': '/lists/ownerships.json', + 'method': 'GET' + }, # Saved Searches