Added tutorial 2 and introduction.
authorJosh Roesslein <jroesslein@gmail.com>
Sat, 8 Aug 2009 19:42:26 +0000 (14:42 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Sat, 8 Aug 2009 19:42:26 +0000 (14:42 -0500)
tutorial/t0.py [new file with mode: 0644]
tutorial/t1.py [moved from tutorial/1.py with 100% similarity]
tutorial/t2.py [new file with mode: 0644]

diff --git a/tutorial/t0.py b/tutorial/t0.py
new file mode 100644 (file)
index 0000000..3735d1c
--- /dev/null
@@ -0,0 +1,14 @@
+""" Introduction
+
+This series of tutorials is designed to introduce you to key
+concepts of Tweepy. By the end of this series you should be ready
+to create your grand Twitter application with Tweepy!
+
+If you get lost on your journey to becoming a Tweepy guru, feel
+free to post questions to tweepy@googlegroups.com
+
+Each tutorial file is named tX.py where X is the tutorial number.
+Work your way from 1 and up.
+
+Author: Joshua Roesslein
+"""
similarity index 100%
rename from tutorial/1.py
rename to tutorial/t1.py
diff --git a/tutorial/t2.py b/tutorial/t2.py
new file mode 100644 (file)
index 0000000..75d85a9
--- /dev/null
@@ -0,0 +1,62 @@
+import tweepy
+from t1 import *
+
+""" Tutorial 2 -- API
+
+This tutorial will focus on creating and using the API class.
+The API class is the primary interface between your application
+and Twitter's API. It implements most of the endpoint documented here:
+    http://apiwiki.twitter.com/Twitter-API-Documentation
+"""
+
+"""
+The API class can be used in either authenticated or non-authenticated modes.
+First let's demonstrate using the API class without authentication...
+"""
+no_auth_api = tweepy.API()
+
+"""
+Let's query the public timeline and print it to the console...
+"""
+public_timeline = no_auth_api.public_timeline()
+print 'Public timeline...'
+for status in public_timeline:
+  print status.text
+  print 'from: %s' % status.user.screen_name
+
+"""
+Tweepy provides a non-authenticated instance of the API for you already
+so you don't normally need to create one your self.
+"""
+tweepy.api  # non-auth instance of API
+
+"""
+Any endpoint that does not require authentication can be accessed 
+with this non-authenticated API instance. If you try to access an
+API endpoint that does require authentication, a TweepError exception
+will be raised.
+"""
+
+"""
+Now we will create an authenticated instance of the API class
+using the auth handler we created in tutorial 1.
+"""
+auth_api = tweepy.API(oauth_auth)
+
+"""
+Let's query the authenticated user's friends timeline
+and print it to the console...
+"""
+friends_timeline = auth_api.friends_timeline()
+for status in friends_timeline:
+  print status.text
+  print 'from: %s' % status.user.screen_name
+
+""" The End
+
+So that wraps up this tutorial. You now know how to create both
+non-authenticated and authenticated instances of the API class.
+
+Onto the next tutorial!
+"""
+