Implement requests #65

Merged
michaelhelmick merged 3 commits from implement_requests into master 2012-03-18 06:56:35 -07:00
2 changed files with 24 additions and 43 deletions
Showing only changes of commit 158bf77231 - Show all commits

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
import sys, os
from setuptools import setup from setuptools import setup
from setuptools import find_packages from setuptools import find_packages
@ -9,25 +8,25 @@ __version__ = '1.4.6'
setup( setup(
# Basic package information. # Basic package information.
name = 'twython', name='twython',
version = __version__, version=__version__,
packages = find_packages(), packages=find_packages(),
# Packaging options. # Packaging options.
include_package_data = True, include_package_data=True,
# Package dependencies. # Package dependencies.
install_requires = ['simplejson', 'oauth2', 'httplib2', 'requests'], install_requires=['simplejson', 'oauth2', 'requests', 'requests-oauth'],
# Metadata for PyPI. # Metadata for PyPI.
author = 'Ryan McGrath', author='Ryan McGrath',
author_email = 'ryan@venodesigns.net', author_email='ryan@venodesigns.net',
license = 'MIT License', license='MIT License',
url = 'http://github.com/ryanmcgrath/twython/tree/master', url='http://github.com/ryanmcgrath/twython/tree/master',
keywords = 'twitter search api tweet twython', keywords='twitter search api tweet twython',
description = 'An easy (and up to date) way to access Twitter data with Python.', description='An easy (and up to date) way to access Twitter data with Python.',
long_description = open('README.markdown').read(), long_description=open('README.markdown').read(),
classifiers = [ classifiers=[
'Development Status :: 4 - Beta', 'Development Status :: 4 - Beta',
'Intended Audience :: Developers', 'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License', 'License :: OSI Approved :: MIT License',

View file

@ -12,7 +12,6 @@ __author__ = "Ryan McGrath <ryan@venodesigns.net>"
__version__ = "1.4.6" __version__ = "1.4.6"
import urllib import urllib
import urllib2
import re import re
import inspect import inspect
import time import time
@ -31,7 +30,6 @@ except ImportError:
# table is a file with a dictionary of every API endpoint that Twython supports. # table is a file with a dictionary of every API endpoint that Twython supports.
from twitter_endpoints import base_url, api_table from twitter_endpoints import base_url, api_table
from urllib2 import HTTPError
# There are some special setups (like, oh, a Django application) where # There are some special setups (like, oh, a Django application) where
# simplejson exists behind the scenes anyway. Past Python 2.6, this should # simplejson exists behind the scenes anyway. Past Python 2.6, this should
@ -272,22 +270,6 @@ class Twython(object):
def constructApiURL(base_url, params): def constructApiURL(base_url, params):
return base_url + "?" + "&".join(["%s=%s" % (Twython.unicode2utf8(key), urllib.quote_plus(Twython.unicode2utf8(value))) for (key, value) in params.iteritems()]) return base_url + "?" + "&".join(["%s=%s" % (Twython.unicode2utf8(key), urllib.quote_plus(Twython.unicode2utf8(value))) for (key, value) in params.iteritems()])
@staticmethod
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")
Shortens url specified by url_to_shorten.
Parameters:
url_to_shorten - URL to shorten.
shortener - In case you want to use a url shortening service other than is.gd.
"""
try:
content = urllib2.urlopen(shortener + "?" + urllib.urlencode({query: Twython.unicode2utf8(url_to_shorten)})).read()
return content
except HTTPError, e:
raise TwythonError("shortenURL() failed with a %s error code." % e.code)
def bulkUserLookup(self, ids=None, screen_names=None, version=1, **kwargs): def bulkUserLookup(self, ids=None, screen_names=None, version=1, **kwargs):
""" bulkUserLookup(self, ids = None, screen_names = None, version = 1, **kwargs) """ bulkUserLookup(self, ids = None, screen_names = None, version = 1, **kwargs)