Boston Python Workshop 4/Twitter: Difference between revisions

From OpenHatch wiki
Content added Content deleted
imported>Jesstess
No edit summary
imported>Jesstess
No edit summary
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
See the [http://openhatch.org/wiki/Boston_Python_Workshop_4/Friday Friday setup instructions].
See the [http://openhatch.org/wiki/Boston_Python_Workshop_4/Friday Friday setup instructions].


==Goals==
==Handout==


[[Boston_Python_Workshop_4/Twitter_handout| Twitter handout]]: goals and cheat sheet.
* Have fun playing with data from Twitter.
* See how easy it is to programmatically gather data from social websites that have APIs.
* Get experience with command line option parsing and passing data to a Python script.
* Get experience reading other people's code.


<hr />
==Suggested exercises==


[[Boston Python Workshop 4/Saturday projects|&laquo; Back to the Saturday Projects page]]
<ul>
<li>
Customize how tweets are displayed. Look at the <code>Status</code> and <code>User</code> classes in the [http://code.google.com/p/python-twitter/source/browse/twitter.py| Twitter code] for inspiration; options include the URL for the tweet, how many followers the sender has, the location of the sender, and if it was a retweet.
</li>
<li>
Write a new function to display tweets from all the trending topics. Add a new command line option for this function.
</li>
<li>
The code to display tweets gets re-used several times. De-duplicate the code by moving it into a function and calling that function instead. Example prototype:


[[Boston Python Workshop 4|&laquo; to the Workshop home page]]
<pre>
def print_tweet(tweet):
"""
tweet is an instance of twitter.Status.
"""
pass
</pre>
</li>
<li>[Long] A lot of the Twitter API requires that you be authenticated. Examples of actions that require authentication include: posting new tweets, getting a user's followers, getting private tweets from your friends, and following new people.

Set up oAuth so you can make authenticated requests.

http://dev.twitter.com/pages/auth describe how Twitter uses oAuth.

http://code.google.com/p/python-twitter/ has examples of using oAuth authentication to make authenticated Twitter API requests.
</li>
</ul>

[[Boston Python Workshop 4/Saturday projects|&laquo; Back to the Saturday project page]]

Latest revision as of 03:43, 30 September 2011

Use the Twitter API to write the basic parts of a Twitter client. See what your friends are tweeting, get trending topics, search tweets, and more.

Setup

See the Friday setup instructions.

Handout

Twitter handout: goals and cheat sheet.


« Back to the Saturday Projects page

« to the Workshop home page