Skip to content

Instantly share code, notes, and snippets.

@showyou
Created October 16, 2009 22:23
Show Gist options
  • Save showyou/212120 to your computer and use it in GitHub Desktop.
Save showyou/212120 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from twisted.internet import reactor
from twisted.web import client
import urllib2
def printPage(data):
print data
reactor.stop()
def printError(failure):
print 'Error: %s' % failure.getErrorMessage()
reactor.stop()
def get(callbackfunc,errfunc = printError):
u = urllib2.HTTPPasswordMgr()
u.add_password('Twitter API', 'http://twitter.com/', 'user', 'pass')
d = client.getPage('http://twitter.com/statuses/friends_timeline.json', passwdMgr=u)
#d = client.getPage('http://twitter.com/statuses/public_timeline.json')
d.addCallback(callbackfunc)
d.addErrback(errfunc)
reactor.run()
def main():
get(printPage)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment