from urllib2 import * from xml.dom.minidom import parse from time import sleep,localtime,strftime # Get api_key and secret_key from a file fbs = open('facebook_keys.txt').readlines() facebook = Facebook(fbs[0].strip(), fbs[1].strip()) while True: print strftime("%a, %d %b %Y %H:%M:%S", localtime()) try: session = load(file(".session")) print session facebook.secret = session['secret'] facebook.session_key = session['session_key'] facebook.session_key_expires = session['expires'] facebook.uid = session['uid'] except (EOFError,IOError): token = facebook.auth.createToken() print "token",facebook.auth._client.auth_token # Show login window facebook.login() # Login to the window, then press enter print 'After logging in, press enter...' raw_input() res = facebook.auth.getSession() dump(res,file(".session","w")) try: data = parse(urlopen("http://twitter.com/statuses/user_timeline/palfrey.xml"))