parent
a6afb2cf5c
commit
7d1ffefc45
1 changed files with 16 additions and 24 deletions
|
|
@ -99,7 +99,6 @@ class Twython(object):
|
||||||
self.api_url = 'https://api.twitter.com/%s'
|
self.api_url = 'https://api.twitter.com/%s'
|
||||||
self.request_token_url = self.api_url % 'oauth/request_token'
|
self.request_token_url = self.api_url % 'oauth/request_token'
|
||||||
self.access_token_url = self.api_url % 'oauth/access_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'
|
self.authenticate_url = self.api_url % 'oauth/authenticate'
|
||||||
|
|
||||||
# Enforce unicode on keys and secrets
|
# Enforce unicode on keys and secrets
|
||||||
|
|
@ -265,8 +264,11 @@ class Twython(object):
|
||||||
return self._last_call['headers'][header]
|
return self._last_call['headers'][header]
|
||||||
return self._last_call
|
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.
|
"""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 = {}
|
request_args = {}
|
||||||
if self.callback_url:
|
if self.callback_url:
|
||||||
|
|
@ -287,6 +289,12 @@ class Twython(object):
|
||||||
'oauth_token': request_tokens['oauth_token'],
|
'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
|
# Use old-style callback argument if server didn't accept new-style
|
||||||
if self.callback_url and not oauth_callback_confirmed:
|
if self.callback_url and not oauth_callback_confirmed:
|
||||||
auth_url_params['oauth_callback'] = self.callback_url
|
auth_url_params['oauth_callback'] = self.callback_url
|
||||||
|
|
@ -453,28 +461,12 @@ class Twython(object):
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
def getProfileImageUrl(self, username, size='normal', version='1'):
|
def getProfileImageUrl(self, username, size='normal', version='1'):
|
||||||
"""Gets the URL for the user's profile image.
|
warnings.warn(
|
||||||
|
"This function has been deprecated. Twitter API v1.1 will not have a dedicated endpoint \
|
||||||
:param username: (required) Username, self explanatory.
|
for this functionality.",
|
||||||
:param size: (optional) Default 'normal' (48px by 48px)
|
DeprecationWarning,
|
||||||
bigger - 73px by 73px
|
stacklevel=2
|
||||||
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)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def stream(data, callback):
|
def stream(data, callback):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue