Cleaning up endpoints per Twitter Spring 2012 deprecations
https://dev.twitter.com/docs/deprecations/spring-2012
This commit is contained in:
parent
ac18837ed6
commit
0ee5e5877e
2 changed files with 32 additions and 44 deletions
|
|
@ -32,10 +32,6 @@ api_table = {
|
|||
},
|
||||
|
||||
# Timeline methods
|
||||
'getPublicTimeline': {
|
||||
'url': '/statuses/public_timeline.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getHomeTimeline': {
|
||||
'url': '/statuses/home_timeline.json',
|
||||
'method': 'GET',
|
||||
|
|
@ -44,24 +40,12 @@ api_table = {
|
|||
'url': '/statuses/user_timeline.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFriendsTimeline': {
|
||||
'url': '/statuses/friends_timeline.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
# Interfacing with friends/followers
|
||||
'getUserMentions': {
|
||||
'url': '/statuses/mentions.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFriendsStatus': {
|
||||
'url': '/statuses/friends.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFollowersStatus': {
|
||||
'url': '/statuses/followers.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'createFriendship': {
|
||||
'url': '/friendships/create.json',
|
||||
'method': 'POST',
|
||||
|
|
@ -126,7 +110,7 @@ api_table = {
|
|||
|
||||
# Status methods - showing, updating, destroying, etc.
|
||||
'showStatus': {
|
||||
'url': '/statuses/show/{{id}}.json',
|
||||
'url': '/statuses/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'updateStatus': {
|
||||
|
|
@ -254,60 +238,64 @@ api_table = {
|
|||
|
||||
# List API methods/endpoints. Fairly exhaustive and annoying in general. ;P
|
||||
'createList': {
|
||||
'url': '/{{username}}/lists.json',
|
||||
'url': '/lists/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateList': {
|
||||
'url': '/{{username}}/lists/{{list_id}}.json',
|
||||
'url': '/lists/update.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'showLists': {
|
||||
'url': '/{{username}}/lists.json',
|
||||
'url': '/lists.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListMemberships': {
|
||||
'url': '/{{username}}/lists/memberships.json',
|
||||
'url': '/lists/memberships.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListSubscriptions': {
|
||||
'url': '/{{username}}/lists/subscriptions.json',
|
||||
'url': '/lists/subscriptions.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'deleteList': {
|
||||
'url': '/{{username}}/lists/{{list_id}}.json',
|
||||
'method': 'DELETE',
|
||||
'url': '/lists/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getListTimeline': {
|
||||
'url': '/{{username}}/lists/{{list_id}}/statuses.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getSpecificList': {
|
||||
'url': '/{{username}}/lists/{{list_id}}/statuses.json',
|
||||
'url': '/lists/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListStatuses': {
|
||||
'url': '/lists/statuses.json',
|
||||
'method': 'GET'
|
||||
},
|
||||
'addListMember': {
|
||||
'url': '/{{username}}/{{list_id}}/members.json',
|
||||
'url': '/lists/members/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getListMembers': {
|
||||
'url': '/{{username}}/{{list_id}}/members.json',
|
||||
'url': '/lists/members.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'deleteListMember': {
|
||||
'url': '/{{username}}/{{list_id}}/members.json',
|
||||
'method': 'DELETE',
|
||||
'url': '/lists/members/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getListSubscribers': {
|
||||
'url': '/{{username}}/{{list_id}}/subscribers.json',
|
||||
'url': '/lists/subscribers.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'subscribeToList': {
|
||||
'url': '/{{username}}/{{list_id}}/subscribers.json',
|
||||
'url': '/lists/subscribers/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'unsubscribeFromList': {
|
||||
'url': '/{{username}}/{{list_id}}/subscribers.json',
|
||||
'method': 'DELETE',
|
||||
'url': '/lists/subscribers/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
# The one-offs
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ class TwythonError(AttributeError):
|
|||
twitter_http_status_codes[error_code][1],
|
||||
self.msg)
|
||||
|
||||
if error_code == 400 or error_code == 420:
|
||||
if error_code == 420:
|
||||
raise TwythonRateLimitError(self.msg,
|
||||
error_code,
|
||||
retry_after=retry_after)
|
||||
|
|
@ -94,9 +94,9 @@ class TwythonRateLimitError(TwythonError):
|
|||
retry_wait_seconds is the number of seconds to wait before trying again.
|
||||
"""
|
||||
def __init__(self, msg, error_code, retry_after=None):
|
||||
if isinstance(retry_after, int):
|
||||
retry_after = int(retry_after)
|
||||
self.msg = '%s (Retry after %s seconds)' % (msg, retry_after)
|
||||
TwythonError.__init__(self, msg, error_code)
|
||||
|
||||
def __str__(self):
|
||||
return repr(self.msg)
|
||||
|
|
@ -175,11 +175,11 @@ class Twython(object):
|
|||
OAuthHook.consumer_secret = twitter_secret
|
||||
|
||||
# Needed for hitting that there API.
|
||||
self.request_token_url = 'https://twitter.com/oauth/request_token'
|
||||
self.access_token_url = 'https://twitter.com/oauth/access_token'
|
||||
self.authorize_url = 'https://twitter.com/oauth/authorize'
|
||||
self.authenticate_url = 'https://twitter.com/oauth/authenticate'
|
||||
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.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.twitter_token = twitter_token
|
||||
self.twitter_secret = twitter_secret
|
||||
|
|
@ -299,7 +299,7 @@ class Twython(object):
|
|||
if endpoint.startswith('http://') or endpoint.startswith('https://'):
|
||||
url = endpoint
|
||||
else:
|
||||
url = '%s%s.json' % (self.api_url % version, endpoint)
|
||||
url = '%s/%s.json' % (self.api_url % version, endpoint)
|
||||
|
||||
content = self._request(url, method=method, params=params, api_call=url)
|
||||
|
||||
|
|
@ -694,7 +694,7 @@ class Twython(object):
|
|||
"""
|
||||
|
||||
endpoint = 'users/profile_image/%s' % username
|
||||
url = self.api_url % version + endpoint + '?' + urllib.urlencode({'size': size})
|
||||
url = self.api_url % version + '/' + endpoint + '?' + urllib.urlencode({'size': size})
|
||||
|
||||
response = self.client.get(url, allow_redirects=False)
|
||||
image_url = response.headers.get('location')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue