Dynamic callback url works again, PEP8 clean up #69
1 changed files with 75 additions and 74 deletions
|
|
@ -95,6 +95,7 @@ class TwythonAPILimit(TwythonError):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self.msg)
|
return repr(self.msg)
|
||||||
|
|
||||||
|
|
||||||
class APILimit(TwythonError):
|
class APILimit(TwythonError):
|
||||||
"""
|
"""
|
||||||
Raised when you've hit an API limit. Try to avoid these, read the API
|
Raised when you've hit an API limit. Try to avoid these, read the API
|
||||||
|
|
@ -291,7 +292,7 @@ class Twython(object):
|
||||||
# ------------------------------------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def shortenURL(url_to_shorten, shortener = "http://is.gd/api.php", query="longurl"):
|
def shortenURL(url_to_shorten, shortener="http://is.gd/api.php", query="longurl"):
|
||||||
"""
|
"""
|
||||||
shortenURL(url_to_shorten, shortener = "http://is.gd/api.php", query="longurl")
|
shortenURL(url_to_shorten, shortener = "http://is.gd/api.php", query="longurl")
|
||||||
|
|
||||||
|
|
@ -303,14 +304,14 @@ class Twython(object):
|
||||||
url_to_shorten - URL to shorten.
|
url_to_shorten - URL to shorten.
|
||||||
shortener = In case you want to use a url shortening service other than is.gd.
|
shortener = In case you want to use a url shortening service other than is.gd.
|
||||||
"""
|
"""
|
||||||
request = requests.get('http://is.gd/api.php' , params = {
|
request = requests.get('http://is.gd/api.php', params={
|
||||||
'query': url_to_shorten
|
'query': url_to_shorten
|
||||||
})
|
})
|
||||||
|
|
||||||
if r.status_code in [301, 201, 200]:
|
if request.status_code in [301, 201, 200]:
|
||||||
return request.text
|
return request.text
|
||||||
else:
|
else:
|
||||||
raise TwythonError('shortenURL() failed with a %s error code.' % r.status_code)
|
raise TwythonError('shortenURL() failed with a %s error code.' % request.status_code)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def constructApiURL(base_url, params):
|
def constructApiURL(base_url, params):
|
||||||
|
|
@ -462,7 +463,7 @@ class Twython(object):
|
||||||
"""
|
"""
|
||||||
return self._media_update('http://api.twitter.com/%d/account/update_profile_background_image.json' % version, {
|
return self._media_update('http://api.twitter.com/%d/account/update_profile_background_image.json' % version, {
|
||||||
'image': (file_, open(file_, 'rb'))
|
'image': (file_, open(file_, 'rb'))
|
||||||
}, params = {'tile': tile})
|
}, params={'tile': tile})
|
||||||
|
|
||||||
def updateProfileImage(self, file_, version=1):
|
def updateProfileImage(self, file_, version=1):
|
||||||
""" updateProfileImage(filename)
|
""" updateProfileImage(filename)
|
||||||
|
|
@ -614,13 +615,13 @@ class Twython(object):
|
||||||
password = data.pop('password')
|
password = data.pop('password')
|
||||||
|
|
||||||
if needs_basic_auth:
|
if needs_basic_auth:
|
||||||
stream = requests.post(endpoint, data = data, auth = (username, password))
|
stream = requests.post(endpoint, data=data, auth=(username, password))
|
||||||
else:
|
else:
|
||||||
stream = requests.post(endpoint, data = data)
|
stream = requests.post(endpoint, data=data)
|
||||||
|
|
||||||
for line in stream.iter_lines():
|
for line in stream.iter_lines():
|
||||||
if line:
|
if line:
|
||||||
callback(json.loads(line))
|
callback(simplejson.loads(line))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def unicode2utf8(text):
|
def unicode2utf8(text):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue