Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
c64242b4
Commit
c64242b4
authored
Aug 14, 2009
by
Josh Roesslein
Browse files
Added API.new() method. Updated tweepyshell.
parent
57c5488e
Changes
4
Hide whitespace changes
Inline
Side-by-side
CHANGES
View file @
c64242b4
...
...
@@ -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: API.new(auth='basic', username='testuser', password='testpass')
+ Fixes
+ User.following is now set to False instead of None
when user is not followed.
tweepy/api.py
View file @
c64242b4
...
...
@@ -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
@
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'
,
...
...
tweepy/auth.py
View file @
c64242b4
...
...
@@ -85,6 +85,4 @@ class OAuthHandler(AuthHandler):
return
self
.
access_token
except
Exception
,
e
:
raise
TweepError
(
e
)
tweepyshell.py
View file @
c64242b4
...
...
@@ -17,7 +17,7 @@ if len(sys.argv) != 3:
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment