Monday, September 28, 2009

Twitter Application with Google App Engine/Python

Setup


To get started, you will need

  • Python 2.5.2 - According to Google App Engine documentation here - make sure to use the right version to avoid any compatibility issues
  • Eclipse - IDE - makes your life easier
  • PyDev- Eclipse Plugin to support Python - to install : in Eclipse, go to Help -> Software Updates -> Add Site : http://pydev.org/updates
  • Google App Engine SDK - get the latest version .msi file. double click
  • Tweepy - best damn Twitter/Python API to date
    • If you have git installed: 1. clone the repository from github 2. in the tweepy directory, type in setup.py install
    • If you don't have git, download the archive from the site, unzip, and follow 2. from above
  • Github - optional - it's a good practice to use SCM for your code. I wrote the following article on how to use it with Eclipse
    • I won't be discussing how to commit your code (atleast here). If you want to maintain sanity, I suggest you use an SCM of some sort

Screwing Around with Tweepy

Next we're going to console use the Python console to experiment with the Twitter API. Please note, text in Courier New is meant to be executed in a Python shell

>>> import tweepy # if this worked, you installed it correctly

There are two way to get authenticated with Twitter. With an authenticated Twitter API you can do all the things you can do with a twitter account: post messages, read your DM, etc.
  1. via username and password ( basic authentication )
  2. OAuth - requires registering your app here.

>>> twitter = tweepy.API.new('basic','twitter_account_name','twitter_account_password')

if this worked, you're in! Let's try to update your status

>>> twitter.update_status("I'm using the internet!")

So now that you have the Twitter API working, go through tweepy's API/tutorials to figure out what it can do. Try calling other methods on the twitter class. See what happens. If you're reading this tutorial, you're probably ahead of my on this one


Setting Up Eclipse


Follow the Configuring Eclipse on Windows to Use With Google App Engine tutorial. It's pretty detailed.

Google App Engine requires you to upload all the extra libraries you need to appspot in order for you app to work. This means you need to add the tweepy library to your project:

  1. open the directory where you installed tweepy above in Explorer
  2. Drag&Drop the whole tweepy directory in build\lib\ into the \src folder
  3. Tweepy is installed - use it


Making the App


We're going to make a simple app. It will
  • run a search on all public tweets for the phrase "#python"
  • store the results
  • display the top 20

To do so, we will need two scripts files to execute
  1. show.py - shows top 20 tweets
  2. update.py - performs searches at 5 minute intervals

and a common library file to store stuff ( common.py )

stay tuned for Part 2



Sunday, September 27, 2009

Git + Eclipse

In short what you need to do is
  1. In Eclipse, go to Help -> Software Updates and add the following address http://www.jgit.org/updates .
  2. Click install and you're done
  3. Click on a file in Eclipse, and under the 'Team' menu, you'll find Git options
  4. Profit
Look through these links for more info

Thursday, September 24, 2009

Memeoized


I'm writing a new twitter app: Memeoized. See it in action at twitter.com/memeoized

Idea: 'scour' twitter for people mentioning memes and report the memes with a (@) . Simple enough idea but I kind of like it.

I'm able to reuse most of the code from NYCGameTrade because the idea is so similar. Exept this time I'll keep myself to a single blog.

Here is my resource list

and we're up and running

Tuesday, September 15, 2009

How quickly ideas die - NYCGameTrade

Yes. I'm blogging about another blog. Yes. it was a big failure. No. there were no lessons learned.



I wrote a Google App Engine service that would poll a twitter account, see if anyone twittered anything with #ps3 or #xbox tags at the account, and re-tweet the request. The blog details some of my attempts to woo an audience such as posting to CL news ( useless ), posting to as a CL ad ( deleted ), posting to meetup ( ignored ). 

Why would I bother with this ? have you not seen this: http://ggodik.blogspot.com/search/label/games . Most of what I do is trade games on CraigsList, play em, and swap-em-out again. Rinse. Repeat.

Why did I do this ? honestly, just to try out Google App Engine, code in Eclipse again, and to screw around with Twitter. I have
  • downloaded every twitter python api library and determined they're mostly garbage
  • messed around with Google App Engine to discover how awesome Google did at hosting application. And they keep releasing features! And the whole thing works!
  • to fail miserably at something web2.0ish

Will this deter me ? Probably now. I think I'm going to make my system generate DM message spam. Should it deter me ? Probably.