Merge 600f36c6ba into 0e258fe1a1
This commit is contained in:
commit
26c689beee
12 changed files with 181 additions and 100 deletions
|
|
@ -1,6 +1,11 @@
|
|||
History
|
||||
-------
|
||||
|
||||
2.9.1 (2013-05-04)
|
||||
++++++++++++++++++
|
||||
|
||||
- "PEP8" all the functions. Switch functions from camelCase() to underscore_funcs(). (i.e. ``updateStatus()`` is now ``update_status()``)
|
||||
|
||||
2.9.0 (2013-05-04)
|
||||
++++++++++++++++++
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ auth_tokens = t.get_authorized_tokens(oauth_verifier)
|
|||
print auth_tokens
|
||||
```
|
||||
|
||||
*Function definitions (i.e. getHomeTimeline()) can be found by reading over twython/endpoints.py*
|
||||
*Function definitions (i.e. get_home_timeline()) can be found by reading over twython/endpoints.py*
|
||||
|
||||
##### Getting a user home timeline
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ t = Twython(app_key, app_secret,
|
|||
oauth_token, oauth_token_secret)
|
||||
|
||||
# Returns an dict of the user home timeline
|
||||
print t.getHomeTimeline()
|
||||
print t.get_home_timeline()
|
||||
```
|
||||
|
||||
##### Catching exceptions
|
||||
|
|
@ -97,7 +97,7 @@ t = Twython(MY_WRONG_APP_KEY, MY_WRONG_APP_SECRET,
|
|||
BAD_OAUTH_TOKEN, BAD_OAUTH_TOKEN_SECRET)
|
||||
|
||||
try:
|
||||
t.verifyCredentials()
|
||||
t.verify_credentials()
|
||||
except TwythonAuthError as e:
|
||||
print e
|
||||
```
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ Handling the callback
|
|||
auth_tokens = t.get_authorized_tokens(oauth_verifier)
|
||||
print auth_tokens
|
||||
|
||||
*Function definitions (i.e. getHomeTimeline()) can be found by reading over twython/endpoints.py*
|
||||
*Function definitions (i.e. get_home_timeline()) can be found by reading over twython/endpoints.py*
|
||||
|
||||
Getting a user home timeline
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -88,7 +88,7 @@ Getting a user home timeline
|
|||
oauth_token, oauth_token_secret)
|
||||
|
||||
# Returns an dict of the user home timeline
|
||||
print t.getHomeTimeline()
|
||||
print t.get_home_timeline()
|
||||
|
||||
|
||||
Catching exceptions
|
||||
|
|
@ -104,7 +104,7 @@ Catching exceptions
|
|||
BAD_OAUTH_TOKEN, BAD_OAUTH_TOKEN_SECRET)
|
||||
|
||||
try:
|
||||
t.verifyCredentials()
|
||||
t.verify_credentials()
|
||||
except TwythonAuthError as e:
|
||||
print e
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from twython import Twython, TwythonError
|
|||
# Requires Authentication as of Twitter API v1.1
|
||||
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
|
||||
try:
|
||||
user_timeline = twitter.getUserTimeline(screen_name='ryanmcgrath')
|
||||
user_timeline = twitter.get_user_timeline(screen_name='ryanmcgrath')
|
||||
except TwythonError as e:
|
||||
print e
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ from twython import Twython, TwythonError
|
|||
# Requires Authentication as of Twitter API v1.1
|
||||
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
|
||||
try:
|
||||
search_results = twitter.search(q="WebsDotCom", rpp="50")
|
||||
search_results = twitter.search(q='WebsDotCom', rpp='50')
|
||||
except TwythonError as e:
|
||||
print e
|
||||
|
||||
for tweet in search_results["results"]:
|
||||
print "Tweet from @%s Date: %s" % (tweet['from_user'].encode('utf-8'),tweet['created_at'])
|
||||
print tweet['text'].encode('utf-8'),"\n"
|
||||
for tweet in search_results['results']:
|
||||
print 'Tweet from @%s Date: %s' % (tweet['from_user'].encode('utf-8'), tweet['created_at'])
|
||||
print tweet['text'].encode('utf-8'), '\n'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from twython import Twython
|
||||
|
||||
# Shortening URLs requires no authentication, huzzah
|
||||
shortURL = Twython.shortenURL('http://www.webs.com/')
|
||||
shortURL = Twython.shorten_url('http://www.webs.com/')
|
||||
|
||||
print shortURL
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ from twython import Twython
|
|||
|
||||
# Requires Authentication as of Twitter API v1.1
|
||||
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
|
||||
twitter.updateProfileImage('myImage.png')
|
||||
twitter.update_profile_image('myImage.png')
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ from twython import Twython, TwythonError
|
|||
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
|
||||
|
||||
try:
|
||||
twitter.updateStatus(status='See how easy this was?')
|
||||
twitter.update_status(status='See how easy this was?')
|
||||
except TwythonError as e:
|
||||
print e
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -4,7 +4,7 @@ import sys
|
|||
from setuptools import setup
|
||||
|
||||
__author__ = 'Ryan McGrath <ryan@venodesigns.net>'
|
||||
__version__ = '2.9.0'
|
||||
__version__ = '2.9.1'
|
||||
|
||||
packages = [
|
||||
'twython'
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Questions, comments? ryan@venodesigns.net
|
|||
"""
|
||||
|
||||
__author__ = 'Ryan McGrath <ryan@venodesigns.net>'
|
||||
__version__ = '2.9.0'
|
||||
__version__ = '2.9.1'
|
||||
|
||||
from .twython import Twython
|
||||
from .streaming import TwythonStreamer
|
||||
|
|
|
|||
|
|
@ -17,38 +17,38 @@ https://dev.twitter.com/docs/api/1.1
|
|||
|
||||
api_table = {
|
||||
# Timelines
|
||||
'getMentionsTimeline': {
|
||||
'get_mentions_timeline': {
|
||||
'url': '/statuses/mentions_timeline.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getUserTimeline': {
|
||||
'get_user_timeline': {
|
||||
'url': '/statuses/user_timeline.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getHomeTimeline': {
|
||||
'get_home_timeline': {
|
||||
'url': '/statuses/home_timeline.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'retweetedOfMe': {
|
||||
'retweeted_of_me': {
|
||||
'url': '/statuses/retweets_of_me.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
|
||||
# Tweets
|
||||
'getRetweets': {
|
||||
'get_retweets': {
|
||||
'url': '/statuses/retweets/{{id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'showStatus': {
|
||||
'show_status': {
|
||||
'url': '/statuses/show/{{id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'destroyStatus': {
|
||||
'destroy_status': {
|
||||
'url': '/statuses/destroy/{{id}}.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateStatus': {
|
||||
'update_status': {
|
||||
'url': '/statuses/update.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
|
@ -57,7 +57,7 @@ api_table = {
|
|||
'method': 'POST',
|
||||
},
|
||||
# See twython.py for update_status_with_media
|
||||
'getOembedTweet': {
|
||||
'get_oembed_tweet': {
|
||||
'url': '/statuses/oembed.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
|
@ -71,321 +71,321 @@ api_table = {
|
|||
|
||||
|
||||
# Direct Messages
|
||||
'getDirectMessages': {
|
||||
'get_direct_messages': {
|
||||
'url': '/direct_messages.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getSentMessages': {
|
||||
'get_sent_messages': {
|
||||
'url': '/direct_messages/sent.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getDirectMessage': {
|
||||
'get_direct_message': {
|
||||
'url': '/direct_messages/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'destroyDirectMessage': {
|
||||
'destroy_direct_message': {
|
||||
'url': '/direct_messages/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'sendDirectMessage': {
|
||||
'send_direct_message': {
|
||||
'url': '/direct_messages/new.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
|
||||
# Friends & Followers
|
||||
'getUserIdsOfBlockedRetweets': {
|
||||
'get_user_ids_of_blocked_retweets': {
|
||||
'url': '/friendships/no_retweets/ids.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFriendsIDs': {
|
||||
'get_friends_ids': {
|
||||
'url': '/friends/ids.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFollowersIDs': {
|
||||
'get_followers_ids': {
|
||||
'url': '/followers/ids.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'lookupFriendships': {
|
||||
'lookup_friendships': {
|
||||
'url': '/friendships/lookup.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getIncomingFriendshipIDs': {
|
||||
'get_incoming_friendship_ids': {
|
||||
'url': '/friendships/incoming.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getOutgoingFriendshipIDs': {
|
||||
'get_outgoing_friendship_ids': {
|
||||
'url': '/friendships/outgoing.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'createFriendship': {
|
||||
'create_friendship': {
|
||||
'url': '/friendships/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'destroyFriendship': {
|
||||
'destroy_friendship': {
|
||||
'url': '/friendships/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateFriendship': {
|
||||
'update_friendship': {
|
||||
'url': '/friendships/update.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'showFriendship': {
|
||||
'show_friendship': {
|
||||
'url': '/friendships/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFriendsList': {
|
||||
'get_friends_list': {
|
||||
'url': '/friends/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getFollowersList': {
|
||||
'get_followers_list': {
|
||||
'url': '/followers/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
|
||||
# Users
|
||||
'getAccountSettings': {
|
||||
'get_account_settings': {
|
||||
'url': '/account/settings.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'verifyCredentials': {
|
||||
'verify_credentials': {
|
||||
'url': '/account/verify_credentials.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'updateAccountSettings': {
|
||||
'update_account_settings': {
|
||||
'url': '/account/settings.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateDeliveryService': {
|
||||
'update_delivery_service': {
|
||||
'url': '/account/update_delivery_device.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateProfile': {
|
||||
'update_profile': {
|
||||
'url': '/account/update_profile.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
# See twython.py for update_profile_background_image
|
||||
'updateProfileColors': {
|
||||
'update_profile_colors': {
|
||||
'url': '/account/update_profile_colors.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
# See twython.py for update_profile_image
|
||||
'listBlocks': {
|
||||
'list_blocks': {
|
||||
'url': '/blocks/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'listBlockIds': {
|
||||
'list_block_ids': {
|
||||
'url': '/blocks/ids.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'createBlock': {
|
||||
'create_block': {
|
||||
'url': '/blocks/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'destroyBlock': {
|
||||
'destroy_block': {
|
||||
'url': '/blocks/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'lookupUser': {
|
||||
'lookup_user': {
|
||||
'url': '/users/lookup.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'showUser': {
|
||||
'show_user': {
|
||||
'url': '/users/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'searchUsers': {
|
||||
'search_users': {
|
||||
'url': '/users/search.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getContributees': {
|
||||
'get_contributees': {
|
||||
'url': '/users/contributees.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getContributors': {
|
||||
'get_contributors': {
|
||||
'url': '/users/contributors.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'removeProfileBanner': {
|
||||
'remove_profile_banner': {
|
||||
'url': '/account/remove_profile_banner.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
# See twython.py for update_profile_banner
|
||||
'getProfileBannerSizes': {
|
||||
'get_profile_banner_sizes': {
|
||||
'url': '/users/profile_banner.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
|
||||
# Suggested Users
|
||||
'getUserSuggestionsBySlug': {
|
||||
'get_user_suggestions_by_slug': {
|
||||
'url': '/users/suggestions/{{slug}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getUserSuggestions': {
|
||||
'get_user_suggestions': {
|
||||
'url': '/users/suggestions.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getUserSuggestionsStatusesBySlug': {
|
||||
'get_user_suggestions_statuses_by_slug': {
|
||||
'url': '/users/suggestions/{{slug}}/members.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
|
||||
# Favorites
|
||||
'getFavorites': {
|
||||
'get_favorites': {
|
||||
'url': '/favorites/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'destroyFavorite': {
|
||||
'destroy_favorite': {
|
||||
'url': '/favorites/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'createFavorite': {
|
||||
'create_favorite': {
|
||||
'url': '/favorites/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
|
||||
# Lists
|
||||
'showLists': {
|
||||
'show_lists': {
|
||||
'url': '/lists/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListStatuses': {
|
||||
'get_list_statuses': {
|
||||
'url': '/lists/statuses.json',
|
||||
'method': 'GET'
|
||||
},
|
||||
'deleteListMember': {
|
||||
'delete_list_member': {
|
||||
'url': '/lists/members/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getListMemberships': {
|
||||
'get_list_memberships': {
|
||||
'url': '/lists/memberships.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListSubscribers': {
|
||||
'get_list_subscribers': {
|
||||
'url': '/lists/subscribers.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'subscribeToList': {
|
||||
'subscribe_to_list': {
|
||||
'url': '/lists/subscribers/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'isListSubscriber': {
|
||||
'is_list_subscriber': {
|
||||
'url': '/lists/subscribers/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'unsubscribeFromList': {
|
||||
'unsubscribe_from_list': {
|
||||
'url': '/lists/subscribers/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'createListMembers': {
|
||||
'create_list_members': {
|
||||
'url': '/lists/members/create_all.json',
|
||||
'method': 'POST'
|
||||
},
|
||||
'isListMember': {
|
||||
'is_list_member': {
|
||||
'url': '/lists/members/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListMembers': {
|
||||
'get_list_members': {
|
||||
'url': '/lists/members.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'addListMember': {
|
||||
'add_list_member': {
|
||||
'url': '/lists/members/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'deleteList': {
|
||||
'delete_list': {
|
||||
'url': '/lists/destroy.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'updateList': {
|
||||
'update_list': {
|
||||
'url': '/lists/update.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'createList': {
|
||||
'create_list': {
|
||||
'url': '/lists/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'getSpecificList': {
|
||||
'get_specific_list': {
|
||||
'url': '/lists/show.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getListSubscriptions': {
|
||||
'get_list_subscriptions': {
|
||||
'url': '/lists/subscriptions.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'deleteListMembers': {
|
||||
'delete_list_members': {
|
||||
'url': '/lists/members/destroy_all.json',
|
||||
'method': 'POST'
|
||||
},
|
||||
'showOwnedLists': {
|
||||
'show_owned_lists': {
|
||||
'url': '/lists/ownerships.json',
|
||||
'method': 'GET'
|
||||
},
|
||||
|
||||
|
||||
# Saved Searches
|
||||
'getSavedSearches': {
|
||||
'get_saved_searches': {
|
||||
'url': '/saved_searches/list.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'showSavedSearch': {
|
||||
'show_saved_search': {
|
||||
'url': '/saved_searches/show/{{id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'createSavedSearch': {
|
||||
'create_saved_search': {
|
||||
'url': '/saved_searches/create.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
'destroySavedSearch': {
|
||||
'destroy_saved_search': {
|
||||
'url': '/saved_searches/destroy/{{id}}.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
|
||||
# Places & Geo
|
||||
'getGeoInfo': {
|
||||
'get_geo_info': {
|
||||
'url': '/geo/id/{{place_id}}.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'reverseGeocode': {
|
||||
'reverse_geocode': {
|
||||
'url': '/geo/reverse_geocode.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'searchGeo': {
|
||||
'search_geo': {
|
||||
'url': '/geo/search.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getSimilarPlaces': {
|
||||
'get_similar_places': {
|
||||
'url': '/geo/similar_places.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'createPlace': {
|
||||
'create_place': {
|
||||
'url': '/geo/place.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
||||
|
||||
# Trends
|
||||
'getPlaceTrends': {
|
||||
'get_place_trends': {
|
||||
'url': '/trends/place.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getAvailableTrends': {
|
||||
'get_available_trends': {
|
||||
'url': '/trends/available.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
'getClosestTrends': {
|
||||
'get_closest_trends': {
|
||||
'url': '/trends/closest.json',
|
||||
'method': 'GET',
|
||||
},
|
||||
|
||||
|
||||
# Spam Reporting
|
||||
'reportSpam': {
|
||||
'report_spam': {
|
||||
'url': '/users/report_spam.json',
|
||||
'method': 'POST',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -82,15 +82,30 @@ class Twython(object):
|
|||
self.client.verify = ssl_verify
|
||||
|
||||
# register available funcs to allow listing name when debugging.
|
||||
def setFunc(key):
|
||||
return lambda **kwargs: self._constructFunc(key, **kwargs)
|
||||
def setFunc(key, deprecated_key=None):
|
||||
return lambda **kwargs: self._constructFunc(key, deprecated_key, **kwargs)
|
||||
for key in api_table.keys():
|
||||
self.__dict__[key] = setFunc(key)
|
||||
|
||||
# Allow for old camelCase functions until Twython 3.0.0
|
||||
if key == 'get_friend_ids':
|
||||
deprecated_key = 'getFriendIDs'
|
||||
elif key == 'get_followers_ids':
|
||||
deprecated_key = 'getFollowerIDs'
|
||||
elif key == 'get_incoming_friendship_ids':
|
||||
deprecated_key = 'getIncomingFriendshipIDs'
|
||||
elif key == 'get_outgoing_friendship_ids':
|
||||
deprecated_key = 'getOutgoingFriendshipIDs'
|
||||
else:
|
||||
deprecated_key = key.title().replace('_', '')
|
||||
deprecated_key = deprecated_key[0].lower() + deprecated_key[1:]
|
||||
|
||||
self.__dict__[deprecated_key] = setFunc(key, deprecated_key)
|
||||
|
||||
# create stash for last call intel
|
||||
self._last_call = None
|
||||
|
||||
def _constructFunc(self, api_call, **kwargs):
|
||||
def _constructFunc(self, api_call, deprecated_key, **kwargs):
|
||||
# Go through and replace any mustaches that are in our API url.
|
||||
fn = api_table[api_call]
|
||||
url = re.sub(
|
||||
|
|
@ -99,6 +114,14 @@ class Twython(object):
|
|||
self.api_url % self.api_version + fn['url']
|
||||
)
|
||||
|
||||
if deprecated_key:
|
||||
# Until Twython 3.0.0 and the function is removed.. send deprecation warning
|
||||
warnings.warn(
|
||||
'`%s` is deprecated, please use `%s` instead.' % (deprecated_key, api_call),
|
||||
TwythonDeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
|
||||
content = self._request(url, method=fn['method'], params=kwargs)
|
||||
|
||||
return content
|
||||
|
|
@ -274,6 +297,10 @@ class Twython(object):
|
|||
|
||||
@staticmethod
|
||||
def shortenURL(url_to_shorten, shortener='http://is.gd/create.php'):
|
||||
return Twython.shorten_url(url_to_shorten, shortener)
|
||||
|
||||
@staticmethod
|
||||
def shorten_url(url_to_shorten, shortener='http://is.gd/create.php'):
|
||||
"""Shortens url specified by url_to_shorten.
|
||||
Note: Twitter automatically shortens all URLs behind their own custom t.co shortener now,
|
||||
but we keep this here for anyone who was previously using it for alternative purposes. ;)
|
||||
|
|
@ -303,9 +330,26 @@ class Twython(object):
|
|||
|
||||
@staticmethod
|
||||
def constructApiURL(base_url, params):
|
||||
warnings.warn(
|
||||
'This method is deprecated, please use `Twython.construct_api_url` instead.',
|
||||
TwythonDeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
return Twython.construct_api_url(base_url, params)
|
||||
|
||||
@staticmethod
|
||||
def construct_api_url(base_url, params):
|
||||
return base_url + '?' + '&'.join(['%s=%s' % (Twython.unicode2utf8(key), quote_plus(Twython.unicode2utf8(value))) for (key, value) in params.iteritems()])
|
||||
|
||||
def searchGen(self, search_query, **kwargs):
|
||||
warnings.warn(
|
||||
'This method is deprecated, please use `search_gen` instead.',
|
||||
TwythonDeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
return self.search_gen(search_query, **kwargs)
|
||||
|
||||
def search_gen(self, search_query, **kwargs):
|
||||
""" Returns a generator of tweets that match a specified query.
|
||||
|
||||
Documentation: https://dev.twitter.com/doc/get/search
|
||||
|
|
@ -339,6 +383,14 @@ class Twython(object):
|
|||
## Media Uploading functions ##############################################
|
||||
|
||||
def updateProfileBackgroundImage(self, file_, version='1.1', **params):
|
||||
warnings.warn(
|
||||
'This method is deprecated, please use `update_profile_background_image` instead.',
|
||||
TwythonDeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
return self.update_profile_background_image(file_, version, **params)
|
||||
|
||||
def update_profile_background_image(self, file_, version='1.1', **params):
|
||||
"""Updates the authenticating user's profile background image.
|
||||
|
||||
:param file_: (required) A string to the location of the file
|
||||
|
|
@ -356,6 +408,14 @@ class Twython(object):
|
|||
version=version)
|
||||
|
||||
def updateProfileImage(self, file_, version='1.1', **params):
|
||||
warnings.warn(
|
||||
'This method is deprecated, please use `update_profile_image` instead.',
|
||||
TwythonDeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
return self.update_profile_image(file_, version, **params)
|
||||
|
||||
def update_profile_image(self, file_, version='1.1', **params):
|
||||
"""Updates the authenticating user's profile image (avatar).
|
||||
|
||||
:param file_: (required) A string to the location of the file
|
||||
|
|
@ -372,6 +432,14 @@ class Twython(object):
|
|||
version=version)
|
||||
|
||||
def updateStatusWithMedia(self, file_, version='1.1', **params):
|
||||
warnings.warn(
|
||||
'This method is deprecated, please use `update_status_with_media` instead.',
|
||||
TwythonDeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
return self.update_status_with_media(file_, version, **params)
|
||||
|
||||
def update_status_with_media(self, file_, version='1.1', **params):
|
||||
"""Updates the users status with media
|
||||
|
||||
:param file_: (required) A string to the location of the file
|
||||
|
|
@ -388,6 +456,14 @@ class Twython(object):
|
|||
version=version)
|
||||
|
||||
def updateProfileBannerImage(self, file_, version='1.1', **params):
|
||||
warnings.warn(
|
||||
'This method is deprecated, please use `update_profile_banner_image` instead.',
|
||||
TwythonDeprecationWarning,
|
||||
stacklevel=2
|
||||
)
|
||||
return self.update_profile_banner_image(file_, version, **params)
|
||||
|
||||
def update_profile_banner_image(self, file_, version='1.1', **params):
|
||||
"""Updates the users profile banner
|
||||
|
||||
:param file_: (required) A string to the location of the file
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue