Commit c64242b4 authored by Josh Roesslein's avatar Josh Roesslein
Browse files

Added method. Updated tweepyshell.

parent 57c5488e
......@@ -10,6 +10,8 @@ during upgrade will be listed here.
+ API:
+ __init__() signature change; no longer accepts 'username' parameter
which is now autodetected.
+ added new() method. shortcut for setting up new API instances
example:'basic', username='testuser', password='testpass')
+ Fixes
+ User.following is now set to False instead of None
when user is not followed.
......@@ -5,6 +5,7 @@
from . binder import bind_api
from . parsers import *
from . error import TweepError
from . auth import BasicAuthHandler, OAuthHandler
"""Twitter API"""
class API(object):
......@@ -22,6 +23,15 @@ class API(object):
# not a good idea to touch these
self._username = None
def new(auth='basic', *args, **kargs):
if auth == 'basic':
return API(BasicAuthHandler(*args, **kargs))
elif auth == 'oauth':
return API(OAuthHandler(*args, **kargs))
raise TweepError('Invalid auth type')
"""Get public timeline"""
public_timeline = bind_api(
path = '/statuses/public_timeline.json',
......@@ -85,6 +85,4 @@ class OAuthHandler(AuthHandler):
return self.access_token
except Exception, e:
raise TweepError(e)
......@@ -17,7 +17,7 @@ if len(sys.argv) != 3:
print 'Usage: tweepyshell <username> <password>'
api = tweepy.API(tweepy.BasicAuthHandler(sys.argv[1], sys.argv[2]))
api ='basic', username=sys.argv[1], password=sys.argv[2])
if api.verify_credentials() is False:
print 'Invalid username and/or password!'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment