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
56ee0eb0
Commit
56ee0eb0
authored
Nov 15, 2014
by
Mark Smith
Browse files
Updated examples to work in Python 3.
parent
615dd86a
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/oauth.py
View file @
56ee0eb0
from
__future__
import
absolute_import
,
print_function
import
tweepy
# == OAuth Authentication ==
...
...
@@ -11,7 +13,7 @@ consumer_key=""
consumer_secret
=
""
# The access tokens can be found on your applications's Details
# page located at https://dev.twitter.com/apps (located
# page located at https://dev.twitter.com/apps (located
# under "Your access token")
access_token
=
""
access_token_secret
=
""
...
...
@@ -24,9 +26,9 @@ api = tweepy.API(auth)
# If the authentication was successful, you should
# see the name of the account print out
print
api
.
me
().
name
print
(
api
.
me
().
name
)
# If the application settings are set for "Read and Write" then
# this line should tweet out the message to your account's
# this line should tweet out the message to your account's
# timeline. The "Read and Write" setting is on https://dev.twitter.com/apps
api
.
update_status
(
'Updating using OAuth authentication via Tweepy!'
)
examples/streaming.py
View file @
56ee0eb0
from
__future__
import
absolute_import
,
print_function
from
tweepy.streaming
import
StreamListener
from
tweepy
import
OAuthHandler
from
tweepy
import
Stream
...
...
@@ -18,11 +20,11 @@ class StdOutListener(StreamListener):
"""
def
on_data
(
self
,
data
):
print
data
print
(
data
)
return
True
def
on_error
(
self
,
status
):
print
status
print
(
status
)
if
__name__
==
'__main__'
:
l
=
StdOutListener
()
...
...
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