reupload
This commit is contained in:
33
env/lib/python3.6/site-packages/examples/oauth.py
vendored
Normal file
33
env/lib/python3.6/site-packages/examples/oauth.py
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
import tweepy
|
||||
|
||||
# == OAuth Authentication ==
|
||||
#
|
||||
# This mode of authentication is the new preferred way
|
||||
# of authenticating with Twitter.
|
||||
|
||||
# The consumer keys can be found on your application's Details
|
||||
# page located at https://dev.twitter.com/apps (under "OAuth settings")
|
||||
consumer_key=""
|
||||
consumer_secret=""
|
||||
|
||||
# The access tokens can be found on your applications's Details
|
||||
# page located at https://dev.twitter.com/apps (located
|
||||
# under "Your access token")
|
||||
access_token=""
|
||||
access_token_secret=""
|
||||
|
||||
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
|
||||
auth.set_access_token(access_token, access_token_secret)
|
||||
|
||||
api = tweepy.API(auth)
|
||||
|
||||
# If the authentication was successful, you should
|
||||
# see the name of the account print out
|
||||
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
|
||||
# timeline. The "Read and Write" setting is on https://dev.twitter.com/apps
|
||||
api.update_status(status='Updating using OAuth authentication via Tweepy!')
|
||||
35
env/lib/python3.6/site-packages/examples/streaming.py
vendored
Normal file
35
env/lib/python3.6/site-packages/examples/streaming.py
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
from __future__ import absolute_import, print_function
|
||||
|
||||
from tweepy.streaming import StreamListener
|
||||
from tweepy import OAuthHandler
|
||||
from tweepy import Stream
|
||||
|
||||
# Go to http://apps.twitter.com and create an app.
|
||||
# The consumer key and secret will be generated for you after
|
||||
consumer_key=""
|
||||
consumer_secret=""
|
||||
|
||||
# After the step above, you will be redirected to your app's page.
|
||||
# Create an access token under the the "Your access token" section
|
||||
access_token=""
|
||||
access_token_secret=""
|
||||
|
||||
class StdOutListener(StreamListener):
|
||||
""" A listener handles tweets that are received from the stream.
|
||||
This is a basic listener that just prints received tweets to stdout.
|
||||
|
||||
"""
|
||||
def on_data(self, data):
|
||||
print(data)
|
||||
return True
|
||||
|
||||
def on_error(self, status):
|
||||
print(status)
|
||||
|
||||
if __name__ == '__main__':
|
||||
l = StdOutListener()
|
||||
auth = OAuthHandler(consumer_key, consumer_secret)
|
||||
auth.set_access_token(access_token, access_token_secret)
|
||||
|
||||
stream = Stream(auth, l)
|
||||
stream.filter(track=['basketball'])
|
||||
Reference in New Issue
Block a user