Merge pull request #69 from michaelhelmick/master
Dynamic callback url works again, PEP8 clean up
This commit is contained in:
commit
861c05718d
2 changed files with 77 additions and 79 deletions
2
setup.py
2
setup.py
|
|
@ -4,7 +4,7 @@ from setuptools import setup
|
|||
from setuptools import find_packages
|
||||
|
||||
__author__ = 'Ryan McGrath <ryan@venodesigns.net>'
|
||||
__version__ = '1.5.0'
|
||||
__version__ = '1.5.1'
|
||||
|
||||
setup(
|
||||
# Basic package information.
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
"""
|
||||
|
||||
__author__ = "Ryan McGrath <ryan@venodesigns.net>"
|
||||
__version__ = "1.5.0"
|
||||
__version__ = "1.5.1"
|
||||
|
||||
import urllib
|
||||
import re
|
||||
|
|
@ -95,6 +95,7 @@ class TwythonAPILimit(TwythonError):
|
|||
def __str__(self):
|
||||
return repr(self.msg)
|
||||
|
||||
|
||||
class APILimit(TwythonError):
|
||||
"""
|
||||
Raised when you've hit an API limit. Try to avoid these, read the API
|
||||
|
|
@ -242,9 +243,6 @@ class Twython(object):
|
|||
request_args['oauth_callback'] = callback_url
|
||||
method = 'get'
|
||||
|
||||
if not OAUTH_LIB_SUPPORTS_CALLBACK:
|
||||
method = 'post'
|
||||
|
||||
func = getattr(self.client, method)
|
||||
response = func(self.request_token_url, data=request_args)
|
||||
|
||||
|
|
@ -294,7 +292,7 @@ class Twython(object):
|
|||
# ------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@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")
|
||||
|
||||
|
|
@ -306,14 +304,14 @@ class Twython(object):
|
|||
url_to_shorten - URL to shorten.
|
||||
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
|
||||
})
|
||||
|
||||
if r.status_code in [301, 201, 200]:
|
||||
if request.status_code in [301, 201, 200]:
|
||||
return request.text
|
||||
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
|
||||
def constructApiURL(base_url, params):
|
||||
|
|
@ -465,7 +463,7 @@ class Twython(object):
|
|||
"""
|
||||
return self._media_update('http://api.twitter.com/%d/account/update_profile_background_image.json' % version, {
|
||||
'image': (file_, open(file_, 'rb'))
|
||||
}, params = {'tile': tile})
|
||||
}, params={'tile': tile})
|
||||
|
||||
def updateProfileImage(self, file_, version=1):
|
||||
""" updateProfileImage(filename)
|
||||
|
|
@ -617,13 +615,13 @@ class Twython(object):
|
|||
password = data.pop('password')
|
||||
|
||||
if needs_basic_auth:
|
||||
stream = requests.post(endpoint, data = data, auth = (username, password))
|
||||
stream = requests.post(endpoint, data=data, auth=(username, password))
|
||||
else:
|
||||
stream = requests.post(endpoint, data = data)
|
||||
stream = requests.post(endpoint, data=data)
|
||||
|
||||
for line in stream.iter_lines():
|
||||
if line:
|
||||
callback(json.loads(line))
|
||||
callback(simplejson.loads(line))
|
||||
|
||||
@staticmethod
|
||||
def unicode2utf8(text):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue