Source

PyCessing / pycessing / data / examples / twitter.cess

#pull status updates for a particular user from the twitter API

import json
import urllib2

mytext = ScreenText(size=15)
updates = []
username = "ladygaga"
twitterapi = "http://api.twitter.com/1/statuses/user_timeline.json?screen_name="

def setup():
    global updates
    
    pycessing.size(800,600)
    pycessing.noLoop = True
    
    request = urllib2.urlopen(twitterapi + username)
    updates = json.load(request)
    

def draw():
    ypos = 10
    for update in updates:
        mytext.setText(update["text"])
        print update["text"]
        mytext.draw(10,ypos)
        ypos += 30