Rewrote example.
authorJosh Roesslein <jroesslein@gmail.com>
Thu, 30 Jul 2009 05:07:26 +0000 (00:07 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Thu, 30 Jul 2009 05:07:26 +0000 (00:07 -0500)
example.py

index 2d5adfcfa9b49a1b2399860299d2e1c1fba1a998..547bbe75fa0f1653601d556ad1c430ca8292e4c3 100644 (file)
@@ -1,11 +1,27 @@
-from api import API
+import tweepy
 
-# Create API object
-api = API()
+print 'An example of using the Tweepy library...'
 
-# Fetch public timeline
-p_timeline = api.public_timeline()
+# Some twitter credentials.
+# Fill these in with your own login credentials.
+username = 'jitterapp'
+password = 'omega123'
+
+# Create an instance of the API object.
+api = tweepy.API(username, password)
+
+# Let's get a list of the statuses on the public timeline
+# and print the texts to the console.
+public_timeline = api.public_timeline()
+for status in public_timeline:
+  print '%s:  %s\n   from %s posted at %s' % (
+      status.user.screen_name, status.text, status.source, status.created_at)
+
+# Now we will update our twitter status
+# and print the text to the console.
+update = api.update_status(status='hello!')
+print 'Update: %s' % update.text
+
+# Get the timeline for the 'twitter' user.
+twitter_timeline = api.user_timeline(screen_name='twitter')
 
-# Print texts of statuses
-for status in p_timeline:
-  print status.text