From 0f617b9d125e8f8e7d3b3161951643f9a3486b68 Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Thu, 30 Jul 2009 18:27:19 -0500 Subject: [PATCH] Update example --- example.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/example.py b/example.py index 48d6e33..123b711 100644 --- a/example.py +++ b/example.py @@ -2,13 +2,15 @@ import tweepy print 'An example of using the Tweepy library...' -# Some twitter credentials. -# Fill these in with your own login credentials. -username = '' -password = '' +# We need an authentication handler to tell twitter who we are. +# First let's make one using basic auth. +basic_auth = tweepy.BasicAuthHandler('tweebly', 'omega1987twitter') -# Create an instance of the API object. -api = tweepy.API(username, password) +# Now a handler for oauth. +oauth_auth = tweepy.OAuthHandler('consumer_key', 'consumer_secrete') + +# Create an instance of the API object and use the basic auth handler. +api = tweepy.API(basic_auth) # Let's get a list of the statuses on the public timeline # and print the texts to the console. @@ -27,7 +29,7 @@ twitter_timeline = api.user_timeline(screen_name='twitter') # You can also setup up a cache. # Here we will use an in-memory cache with a timeout of 60 seconds. -cached_api = tweepy.API(username, password, cache=tweepy.MemoryCache(timeout=60)) +cached_api = tweepy.API(basic_auth, cache=tweepy.MemoryCache(timeout=60)) # First request here will not be cached s = cached_api.get_status(id=123) -- 2.25.1