X-Git-Url: https://jfr.im/git/z_archive/twitter.git/blobdiff_plain/8eba5b42f7d2fdb38b6774e7067bc47fbda38699..d5f58e6e509a562e021442f011ec6277a4a75561:/twitter/api.py diff --git a/twitter/api.py b/twitter/api.py index 6abdd97..f675822 100644 --- a/twitter/api.py +++ b/twitter/api.py @@ -1,4 +1,4 @@ -import urllib2 +import urllib.request, urllib.error, urllib.parse from twitter.twitter_globals import POST_ACTIONS from twitter.auth import NoAuth @@ -110,8 +110,8 @@ class TwitterCall(object): for uripart in self.uriparts: # If this part matches a keyword argument, use the # supplied value otherwise, just use the part. - uriparts.append(unicode(kwargs.pop(uripart, uripart))) - uri = u'/'.join(uriparts) + uriparts.append(str(kwargs.pop(uripart, uripart))) + uri = '/'.join(uriparts) method = "GET" for action in POST_ACTIONS: @@ -142,19 +142,19 @@ class TwitterCall(object): uriBase += '?' + arg_data body = None else: - body = arg_data + body = arg_data.encode('utf8') - req = urllib2.Request(uriBase, body, headers) + req = urllib.request.Request(uriBase, body, headers) try: - handle = urllib2.urlopen(req) + handle = urllib.request.urlopen(req) if "json" == self.format: res = json.loads(handle.read().decode('utf8')) return wrap_response(res, handle.headers) else: return wrap_response( handle.read().decode('utf8'), handle.headers) - except urllib2.HTTPError as e: + except urllib.error.HTTPError as e: if (e.code == 304): return [] else: