+ API:
+ __init__() signature change; no longer accepts 'username' parameter
which is now autodetected.
+ + added new() method. shortcut for setting up new API instances
+ example: API.new(auth='basic', username='testuser', password='testpass')
+ Fixes
+ User.following is now set to False instead of None
when user is not followed.
from . binder import bind_api
from . parsers import *
from . error import TweepError
+from . auth import BasicAuthHandler, OAuthHandler
"""Twitter API"""
class API(object):
# not a good idea to touch these
self._username = None
+ @staticmethod
+ def new(auth='basic', *args, **kargs):
+ if auth == 'basic':
+ return API(BasicAuthHandler(*args, **kargs))
+ elif auth == 'oauth':
+ return API(OAuthHandler(*args, **kargs))
+ else:
+ raise TweepError('Invalid auth type')
+
"""Get public timeline"""
public_timeline = bind_api(
path = '/statuses/public_timeline.json',
print 'Usage: tweepyshell <username> <password>'
exit(1)
-api = tweepy.API(tweepy.BasicAuthHandler(sys.argv[1], sys.argv[2]))
+api = tweepy.API.new(auth='basic', username=sys.argv[1], password=sys.argv[2])
if api.verify_credentials() is False:
print 'Invalid username and/or password!'
exit(1)