Created
October 16, 2009 22:23
-
-
Save showyou/212120 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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