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