TWITTER API and urllib2
42flicks at gmail.com
Tue Jun 10 13:03:20 CEST 2008
On Tue, Jun 10, 2008 at 10:42 PM, Mike <42flicks at gmail.com> wrote:
> I've spent the last couple of nights hacking away at a Python wrapper for
> the Twitter API that I can use for various things.
> I'm having trouble with one of the methods: user_timeline. (
> This is the only method that is returning a HTTP 401. It seems strange and
> I'm not sure how to debug it further as the other methods requring
> authentication work.
> Please keep in mind the code is missing alot of polish :) - Though I'm open
> to suggestions on improvements.
> If anyone is familiar with this I'd really appreciate a hint as it has me
> stumped! (I really need this method for my functionality too!)
> import urllib2, urllib, urlparse
> class TwitterMethods(object):
> def __init__(self):
> def url_request(self,uri,authentication=None):
> auth = urllib2.HTTPBasicAuthHandler()
> netlock = urlparse.urlparse(uri)
> if authentication:
> passwdMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
> auth = urllib2.HTTPBasicAuthHandler(passwdMgr)
> req = urllib2.Request(uri)
> o = urllib2.build_opener(auth)
> f = o.open(req)
> print f.readlines()
> except o.error:
> print "error"
> # print "unknown error"
> def UserTimeline(self,authentication):
> class TwitterAuth(object):
> def __init__(self,username,password):
> self.username = username
> self.password = password
> p = TwitterMethods()
> auth = TwitterAuth('email at gmail.com','password')
I did come across this post:
only mentions it, does not offer a solution.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list