Code Monkey home page Code Monkey logo

twython's Introduction

Twython

Twython is a Python library providing an easy way to access Twitter data. Supports Python 3. It's been battle tested by companies, educational institutions and individuals alike. Try it today!

Note: As of Twython 3.7.0, there's a general call for maintainers put out. If you find the project useful and want to help out, reach out to Ryan with the info from the bottom of this README. Great open source project to get your feet wet with!

Features

  • Query data for:
    • User information
    • Twitter lists
    • Timelines
    • Direct Messages
    • and anything found in the docs
  • Image Uploading:
    • Update user status with an image
    • Change user avatar
    • Change user background image
    • Change user banner image
  • OAuth 2 Application Only (read-only) Support
  • Support for Twitter's Streaming API
  • Seamless Python 3 support!

Installation

Install Twython via pip:

$ pip install twython

If you're on a legacy project that needs Python 2.7 support, you can install the last version of Twython that supported 2.7:

pip install twython==3.7.0`

Or, if you want the code that is currently on GitHub:

git clone git://github.com/ryanmcgrath/twython.git
cd twython
python setup.py install

Documentation

Documentation is available at https://twython.readthedocs.io/en/latest/

Starting Out

First, you'll want to head over to https://apps.twitter.com and register an application!

After you register, grab your applications Consumer Key and Consumer Secret from the application details tab.

The most common type of authentication is Twitter user authentication using OAuth 1. If you're a web app planning to have users sign up with their Twitter account and interact with their timelines, updating their status, and stuff like that this is the authentication for you!

First, you'll want to import Twython

from twython import Twython

Obtain Authorization URL

Now, you'll want to create a Twython instance with your Consumer Key and Consumer Secret:

  • Only pass callback_url to get_authentication_tokens if your application is a Web Application
  • Desktop and Mobile Applications do not require a callback_url
APP_KEY = 'YOUR_APP_KEY'
APP_SECRET = 'YOUR_APP_SECRET'

twitter = Twython(APP_KEY, APP_SECRET)

auth = twitter.get_authentication_tokens(callback_url='http://mysite.com/callback')

From the auth variable, save the oauth_token and oauth_token_secret for later use (these are not the final auth tokens). In Django or other web frameworks, you might want to store it to a session variable

OAUTH_TOKEN = auth['oauth_token']
OAUTH_TOKEN_SECRET = auth['oauth_token_secret']

Send the user to the authentication url, you can obtain it by accessing

auth['auth_url']

Handling the Callback

If your application is a Desktop or Mobile Application oauth_verifier will be the PIN code

After they authorize your application to access some of their account details, they'll be redirected to the callback url you specified in get_authentication_tokens.

You'll want to extract the oauth_verifier from the url.

Django example:

oauth_verifier = request.GET['oauth_verifier']

Now that you have the oauth_verifier stored to a variable, you'll want to create a new instance of Twython and grab the final user tokens

twitter = Twython(
    APP_KEY, APP_SECRET,
    OAUTH_TOKEN, OAUTH_TOKEN_SECRET
)

final_step = twitter.get_authorized_tokens(oauth_verifier)

Once you have the final user tokens, store them in a database for later use::

    OAUTH_TOKEN = final_step['oauth_token']
    OAUTH_TOKEN_SECRET = final_step['oauth_token_secret']

For OAuth 2 (Application Only, read-only) authentication, see our documentation.

Dynamic Function Arguments

Keyword arguments to functions are mapped to the functions available for each endpoint in the Twitter API docs. Doing this allows us to be incredibly flexible in querying the Twitter API, so changes to the API aren't held up from you using them by this library.

Basic Usage

Function definitions (i.e. get_home_timeline()) can be found by reading over twython/endpoints.py

Create a Twython instance with your application keys and the users OAuth tokens

from twython import Twython
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

Authenticated Users Home Timeline

twitter.get_home_timeline()

Updating Status

This method makes use of dynamic arguments, read more about them.

twitter.update_status(status='See how easy using Twython is!')

Advanced Usage

Questions, Comments, etc?

My hope is that Twython is so simple that you'd never have to ask any questions, but if you feel the need to contact me for this (or other) reasons, you can hit me up at [email protected].

Or if I'm to busy to answer, feel free to ping [email protected] as well.

Follow us on Twitter:

Want to help?

Twython is useful, but ultimately only as useful as the people using it (say that ten times fast!). If you'd like to help, write example code, contribute patches, document things on the wiki, tweet about it. Your help is always appreciated!

twython's People

Contributors

bkvirendra avatar cash avatar clayadavis avatar dalleng avatar decause avatar devdave avatar drevicko avatar eriks5 avatar eugenepyvovarov avatar extesy avatar fumieval avatar greedo avatar hades avatar hansenrum avatar hasimir avatar jmdaweb avatar jvanasco avatar kracekumar avatar lucadex avatar lukasa avatar manuelcortez avatar mckellister avatar michaelhelmick avatar myusuf3 avatar philgyford avatar randalldegges-okta-2 avatar ryanmcgrath avatar tushdante avatar u2ft avatar voulnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twython's Issues

Twython is not pip installable

Using python2.6 on Ubuntu 10.04 i receive the following error:

$ pip install twython==1.2

Downloading/unpacking twython==1.2
  Running setup.py egg_info for package twython
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/path/.ve/build/twython/setup.py", line 16, in <module>
        long_description = open("README.markdown").read(),
    IOError: [Errno 2] No such file or directory: 'README.markdown'

Error when getFollowersStatus() only with ID

I get this error:

>>> flw = twitter.getFollowersStatus(id="ebertti", page="0")
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
flw = twitter.getFollowersStatus(id="ebertti", page="0")
File "C:\Python26\lib\site-packages\twython\core.py", line 580, in getFollowersStatus
raise TwythonError("getFollowersStatus() failed with a %s error code." % `e.code`, e.code)
TwythonError: 'getFollowersStatus() failed with a 403 error code.'

in line 574 of core.py need to put a '?' if you ar using only de ID to get a user followers...

if apiURL.find("?") == -1 :
     apiURL += "?"
else
     apiURL += "&"

if page is not None:
    return simplejson.load(self.opener.open(apiURL + "page=%s" % page))
else:
    return simplejson.load(self.opener.open(apiURL + "cursor=%s" % cursor))

I think it will work

Import Statements don't Work

In your examples, you use

import tango
twitter = tango.setup()

Changing to twython,

import twython
twitter = twython.setup()

yields an error "module has no attribute setup"

The import should be:
from twython import twython

even import twython as twython does not work.

Example request

Can one of the example pieces of code show how to try and except TwythonError please? I've tried various ways of wrapping my calls to Twython but can't seem to get it to successfully catch TwythonError (yes, I'm a Python newbie)

searchTwitter() does not encode query

I believe the searchTwitter() method does not encode the query properly.

from twython import Twython
query = ""mountain view""
search_results = twitter.searchTwitter(q=query, rpp=2)
for tweet in search_results["results"]:
print tweet["text"]

Expected result:
Only tweets with the string "mountain view" (name of the city) should appear.

Actual result:
Most returned tweets contain only the word "mountain".

My ugly fix right now is to use urllib.quote_plus(), see below. It gets the expected behavior, but it would be great if this fix were worked into the library.

from twython import Twython
query = ""mountain view""
search_results = twitter.searchTwitter(q=urllib.quote_plus(query), rpp=2)
for tweet in search_results["results"]:
print tweet["text"]

need to revert email.generator._make_boundary() vs. mimetools.choose_boundary()

noticed in 1.4.4 over 1.4.3 that you moved it from email.generator._make_boundary() to mimetools.choose_boundary()... unfortunately, we'll we need to revert this change as the latter is deprecated for 3.x:

$ python2.7 -3
Python 2.7.1 (r271:86882M, Nov 30 2010, 09:39:13) 
[GCC 4.0.1 (Apple Inc. build 5494)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mimetools
__main__:1: DeprecationWarning: in 3.x, mimetools has been removed in favor of the email package

And they really did carry-through with their threat (so the import of twython3k/twython.py fails):

$ python3
Python 3.2 (r32:88452, Feb 20 2011, 11:12:31) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mimetools
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mimetools

why the change from email.generator._make_boundary()? it seems to work fine under both Python 2 & 3:

$ python2.7 -3
Python 2.7.1 (r271:86882M, Nov 30 2010, 09:39:13) 
[GCC 4.0.1 (Apple Inc. build 5494)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import email.generator
>>> email.generator._make_boundary()
'===============1929834788=='
>>> ^D
$ python3
Python 3.2 (r32:88452, Feb 20 2011, 11:12:31) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import email.generator
>>> email.generator._make_boundary()
'===============0161796712942765287=='

Fixing `setup.py` Script

Hi Ryan,

I've been following your project for a while. Wanted to help out a bit with the coding and possibly get some contributions into the core.

One of the problems with the current setuptools script is that it is non-standard, and uses a mix of old and new practices which comes off as confusing, and breaks the installer on certain OS's.

I re-wrote the setup.py script for use with setuptools, using all of the latest setuptools config options that are the norm.

Going to send you a pull request to grab it if you're interested.

AuthError Exception on line 100 broken.

Code :

from twython import twython

try:
twython.setup(username=username, password=password)
except twython.TwythonError, error:
raise forms.ValidationError(error)

Exception Value: init() takes exactly 2 arguments (3 given)
Exception Location: /data/projects/standalone/twython/twython.py in init, line 100

setup.updateStatus() doesn't properly handle in_reply_to_status_id

It is:

return simplejson.load(self.opener.open("http://twitter.com/statuses/update.json?", urllib.urlencode({"status": status}, {"in_reply_to_status_id": in_reply_to_status_id})))

Rather than:

return simplejson.load(self.opener.open("http://twitter.com/statuses/update.json?", urllib.urlencode({"status": status, "in_reply_to_status_id": in_reply_to_status_id})))

OAuth Support

Tango needs support for OAuth based authentication with Twitter. Is there a way to do this framework-agnostic?

twython3k search queries fail due to bytes vs. str

JSON unpack seems to be failing because a bytes object is subjected to a string operation. Repro code plus TB below:

#!/usr/bin/env python3

from pprint import pprint
import twython3k as twython

twitter = twython.Twython()
data = twitter.searchTwitter(q='twython3k')
res = data['results']
for tweet in res:
    pprint(tweet)

'''
Traceback (most recent call last):
  File "twython3k-bug.py", line 7, in <module>
    data = twitter.searchTwitter(q='twython3k')
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages/twython-1.4.3-py3.2.egg/twython3k/twython.py", line 251, in searchTwitter
    return simplejson.loads(content)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/decoder.py", line 345, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: can't use a string pattern on a bytes-like object
'''

below is my half-attempt at a patch, which involves tweaking some stuff which may break other things, but it does work for searches.

$ diff -u twython-*py
--- twython-orig.py     2011-10-04 00:23:10.000000000 -0700
+++ twython-wescpy.py   2011-10-04 13:43:36.000000000 -0700
@@ -194,7 +194,7 @@

        @staticmethod
        def constructApiURL(base_url, params):
-               return base_url + "?" + "&".join(["%s=%s" %(Twython.unicode2utf8(key), urllib.parse.quote_plus(Twython.unicode2utf8(value))) for (key, value) in list(params.items())])
+               return base_url + "?" + "&".join(["%s=%s" % (key, urllib.parse.quote_plus(Twython.unicode2utf8(value))) for (key, value) in list(params.items())])

        @staticmethod
        def shortenURL(url_to_shorten, shortener = "http://is.gd/api.php", query = "longurl"):
@@ -248,7 +248,7 @@
                searchURL = Twython.constructApiURL("http://search.twitter.com/search.json", kwargs)
                try:
                        resp, content = self.client.request(searchURL, "GET")
-                       return simplejson.loads(content)
+                       return simplejson.loads(content.decode('utf-8'))
                except HTTPError as e:
                        raise TwythonError("getSearchTimeline() failed with a %s error code." % repr(e.code), e.code)

other functionality such as userTimeline and verifyCredentials work with or without the patch. at first, i thought the bug was going to be present for all commands that take parameters since clearly those that don't were still working. however, since updateStatus also works, i've got to conclude it's because the problem lies in twython3k.Twython.searchTwitter() which duplicates code in twython3k.Twython.get(). IOW, the bug was fixed in get() but not in searchTwitter() due to similar code being in 2 places. (i understand this may be required since searching is more complex than the other operations.)

getFollowersIDs only returns the first 100 followers

Hello,

I am trying to get the usernames of all followers. However, getFollowersIDs only returns the first page. I have been trying to find documentation for this function but I haven't been able to find any. Am I looking in the wrong place? It seems to me that there should be some input to the function such as a page or a cursor...

This is what I have so far:

from twython import Twython

twitter = Twython()
response = twitter.getFollowersIDs(screen_name = "SCREEN_NAME")

print repr(response)

followers = response['ids']
print str(len(followers))

for follower_id in followers:
print "User with ID %d is following" % follower_id

PIP installation isn't working

Here is the terminal ouput:


$ pip install twython
Downloading/unpacking twython
Downloading twython-1.3.macosx-10.5-fat3.tar.gz (119Kb): 119Kb downloaded
Running setup.py egg_info for package twython
Traceback (most recent call last):
File "", line 14, in
IOError: [Errno 2] No such file or directory: '/Users/francisco/.virtualenvs/giran-site-flask/build/twython/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 14, in

IOError: [Errno 2] No such file or directory: '/Users/francisco/.virtualenvs/giran-site-flask/build/twython/setup.py'


Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/francisco/.pip/pip.log

Raise exceptions on errors

Currently Tango doesn't seem to throw any exceptions at all, but instead returns None, or in some cases, requires you to check an instance var. In addition to that, Tango prints error messages to stdout.

It would be much easier to do error handling if Tango raised exceptions, and it also wouldn't need to print to stdout like that.

Just something to consider.

ImportError: cannot import name Twython

I've installed twython via easy_install, pip and with setup.py and the import is just successful when i do it from the python prompt and being in the directory in which i'd uncompressed the source code.

I just start learning python yesterday but i hace experience with other languajes, it seems to be a problem related to the enviroment variables (PYHONPATH?).

Hope you can help me.
Thanks!

rate limit method not reflecting whitelist status.

I have got my userid whitelisted with twitter. Below is the output
from curl

20000 1266612510 2010-02-19T20:48:30+00:00 20000

However, when I use twython

import twython.core as twython
twitter = twython.setup(username="myusername", password="mypassword")
rateLimit = twitter.getRateLimitStatus(rate_for="myusername")
print rateLimit
{u'reset_time_in_seconds': 1266613344, u'remaining_hits': 150,
u'hourly_limit': 150, u'reset_time': u'Fri Feb 19 21:02:24 +0000
2010'}

it still shows 150 ??

Am I doing something wrong or ?

updateStatus() failed with a 401 error code.

i try this simple example with my twitter account:

twitter = twython.setup(username="ebertti", password="*******")
twitter.updateStatus("test")

and I am getting this error:

Traceback (most recent call last):
     File "<console>", line 1, in <module>
     File "C:\Python26\lib\site-packages\twython\core.py", line 637, in updateStatus
     raise TwythonError("updateStatus() failed with a %s error code." % `e.code`, e.code)
     TwythonError: 'updateStatus() failed with a 401 error code.'

Defect found in search_results.py

Hi,
I found the following defect while running search_results.py in core_examples :

Traceback (most recent call last):
File "search_results.py", line 5, in
search_results = twitter.searchTwitter(q="WebsDotCom", rpp="50")
File "/usr/local/lib/python2.6/dist-packages/twython-1.3.3-py2.6.egg/twython/twython.py", line 267, in searchTwitter
searchURL = Twython.constructApiURL("http://search.twitter.com/search.json", kwargs) + "&" + urllib.urlencode({"q": Twython.unicode2utf8(search_query)})
TypeError: constructApiURL() takes exactly 3 arguments (2 given)

May I know what other arguments am I required to enter?

More descriptive Exceptions

For example (p.s. the method and params I'm passing are for a pull request I'm submitting)

try:
    return t.isListMember(53131724, None, 'ryanmcgrath')
except TwythonError:
    print 'The user isn't part of the list.'

if you just try

return t.isListMember(53131724, None, 'ryanmcgrath')

It will raise
__main__.TwythonError: u'Not Found: The URI requested is invalid or the resource requested, such as a user, does not exists. -- The specified user is not a member of this list'

in self._request() I'm catching the general Twython error, so this is bad. Cause technically excepting TwythonError for self.isListMember() could be excepting any error that Twitter is throwing back and not specifically that 'ryanmcgrath' is not part of the list with id (53131724)

1-char typo in twython3k/twython.py

need a dot (".") between '"&"' and 'join'):

260:        return base_url + "?" + "&"join(["%s=%s" % (key, urllib.parse.quote_plus(Twython.unicode2utf8(value))) for (key, value) in list(params.items())])

Getting rid of OAUTH_CALLBACK?

So, you can't specify your oauth_callback in the request for a token; it must be done in the Twitter application at https://dev.twitter.com

Should we get rid of this whole logic?:

# Try and gauge the old OAuth2 library spec. Versions 1.5 and greater no longer have the callback
# url as part of the request object; older versions we need to patch for Python 2.5... ugh. ;P
OAUTH_CALLBACK_IN_URL = False
OAUTH_LIB_SUPPORTS_CALLBACK = False
if not hasattr(oauth, '_version') or float(oauth._version.manual_verstr) <= 1.4:
    OAUTH_CLIENT_INSPECTION = inspect.getargspec(oauth.Client.request)
    try:
        OAUTH_LIB_SUPPORTS_CALLBACK = 'callback_url' in OAUTH_CLIENT_INSPECTION.args
    except AttributeError:
        # Python 2.5 doesn't return named tuples, so don't look for an args section specifically.
        OAUTH_LIB_SUPPORTS_CALLBACK = 'callback_url' in OAUTH_CLIENT_INSPECTION
else:
    OAUTH_CALLBACK_IN_URL = True

And any places in get_authentication_tokens() where it refs the callback url?

AttributeError: 'Twython' object has no attribute 'auth'

Example from the readme file fails because of undefined auth attribute.

In [1]: from twython import Twython

In [2]: twitter = Twython()

In [3]: results = twitter.search(q="beart")

AttributeError Traceback (most recent call last)
C:\projects\tweetair\tweetair in ()
----> 1 results = twitter.search(q="beart")

C:\projects\tweetair\tweetair\lib\site-packages\twython\twython.pyc in search(self, *_kwargs)
433 kwargs['q'] = urllib.quote_plus(Twython.unicode2utf8(kwargs['q']))
434
--> 435 return self.get('https://search.twitter.com/search.json', params=kwargs)
436
437 def searchGen(self, search_query, *_kwargs):

C:\projects\tweetair\tweetair\lib\site-packages\twython\twython.pyc in get(self, endpoint, params, version)
264 def get(self, endpoint, params=None, version=1):
265 params = params or {}
--> 266 return self.request(endpoint, params=params, version=version)
267
268 def post(self, endpoint, params=None, version=1):

C:\projects\tweetair\tweetair\lib\site-packages\twython\twython.pyc in request(self, endpoint, method, params, version)
258 url = '%s/%s.json' % (self.api_url % version, endpoint)
259
--> 260 content = self._request(url, method=method, params=params, api_call=url)
261
262 return content

C:\projects\tweetair\tweetair\lib\site-packages\twython\twython.pyc in _request(self, url, method, params, api_call)
203
204 func = getattr(self.client, method)
--> 205 response = func(url, data=myargs, auth=self.auth)
206 content = response.content.decode('utf-8')
207

AttributeError: 'Twython' object has no attribute 'auth'

bulkUserLookup() throws error on user names containing non-ASCII characters

Hello again,

Thanks for the super-quick bugfix for encoding search terms! Here is another problem I believe is a bug.

from twython import Twython
twitter = Twython(<credentials go here>)
twitter.bulkUserLookup(screen_names = [u'martinomander'])
twitter.bulkUserLookup(screen_names = [u'Cad\xea'])

The lookup of 'martinomander' works fine. The second user lookup throws this error:

UnicodeEncodeError: 'ascii' codec can't encode character u'\xea' in position 3: ordinal not in range(128)

I got the user "Cadê" searching Twitter for "java" and getting tweet 9325526300758016 back.

/Martin

showStatus call returns TypeError

Hello,
first of all thanks for Twython - you did a good job and produced an easy to use Twitter client.

There seems to be an problem with showStatus method.
Twython instance I use is initialized as authenticated.

Traceback (most recent call last):
  File "teststatus.py", line 15, in 
    status = twitter.showStatus('109023639533387777');
TypeError: get() takes exactly 1 argument (2 given)

Configuration:
Twython 1.4.3
Python 2.6.1
OsX 10.6.8

Thanks for any help.

Daniel

pip package out of date

Hi,

Can you update Twython in the python package index @ http://pypi.python.org/pypi/twython/? The bulk user lookup function broke and was fixed here but the pip package hasn't been updated. I'm working on a app which relies on Twython and it would be nice if I could just upgrade with pip instead of reinstalling from github.

Thanks, great library!

Latest Twython requires requests==0.13.1

Latest Twython fails to import if using an old version of requests, dependencies should be updated to require 0.13.1 at least. Here's the stack trace:

Traceback (most recent call last):
  File "/home/esteve/.virtualenvs/fluidinfo-importer/lib/python2.6/site-packages/discover.py", line 64, in testFailure
    raise exception
ImportError: Failed to import test module: importer.test.test_providers
Traceback (most recent call last):
  File "/home/esteve/.virtualenvs/fluidinfo-importer/lib/python2.6/site-packages/discover.py", line 288, in _find_tests
    module = self._get_module_from_name(name)
  File "/home/esteve/.virtualenvs/fluidinfo-importer/lib/python2.6/site-packages/discover.py", line 266, in _get_module_from_name
    __import__(name)
  File "/home/esteve/git-projects/fluidinfo-importer/importer/test/test_providers.py", line 20, in <module>
    from twython import Twython
  File "/home/esteve/.virtualenvs/fluidinfo-importer/lib/python2.6/site-packages/twython/__init__.py", line 1, in <module>
    from twython import Twython
  File "/home/esteve/.virtualenvs/fluidinfo-importer/lib/python2.6/site-packages/twython/twython.py", line 19, in <module>
    from requests.auth import OAuth1
ImportError: cannot import name OAuth1```

updateProfileImage() failed with a 401 error code.

This is happen only with this method.. I still in session and i send the tokens

        twitter                 =   Twython(
            twitter_token               =   CONSUMER_KEY,
            twitter_secret      =   CONSUMER_SECRET,
            oauth_token         =   profile.oauth_token,
            oauth_token_secret  =   profile.oauth_secret
        )

        twitter.updateProfileImage(url_of_my_image)

AttributeError: 'ConnectionError' object has no attribute 'code'

I don't know why am i getting this error. I'm doing a call loop to the Search API and randomly at some point it stops and i get the following error message

Traceback (most recent call last):
File "search.py", line 43, in
search_results = twitter.searchTwitter(q=ht, rpp="100")
File "/usr/local/lib/python2.7/dist-packages/twython/twython.py", line 462, in searchTwitter
return self.search(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/twython/twython.py", line 457, in search
raise TwythonError("getSearchTimeline() failed with a %s error code." % e.code, e.code)
AttributeError: 'ConnectionError' object has no attribute 'code'

Thanks.

DM support

Hi,

Thanks for the API. Any plans for DM support?

Cheers!

Provide a working setup.py

It's a bit misleading to have a setup.py that doesn't do anything. It seems pretty easy to do this, since all you really need is copy a single file. There must be tons of similar projects with setup.py's that you could base this on.

Get Followers fails for users with more than 5000 followers

The get followers function fails if you have more than 5000 followers. You should use the cursor = -1 attribute along with pagination with the next_cursor_str/previous_cursor_str as mentioned in the Twitter documentation : https://dev.twitter.com/doc/get/followers/ids

followers = twitter.getFollowersIDs(screen_name = "aplusk")

ValueError Traceback (most recent call last)

/Library/Frameworks/Python.framework/Versions/7.0/lib/python2.7/json/decoder.pyc in raw_decode(self, s, idx)
376 obj, end = self.scan_once(s, idx)
377 except StopIteration:
--> 378 raise ValueError("No JSON object could be decoded")
379 return obj, end
380

ValueError: No JSON object could be decoded

Move library to use `requests`

It sucks that we're adding another dependency, but we are using it for file uploading.. I saw that someone had a pull request out for Twython using requests, but it was so far outdated.

Let's try to make this happen? :)

Update Documentation

  • Requirements (2.6~ and below; for 3k, read section further down) section is not needed, when you pip install twython, it automatically installs the requirements specified in the setup file.
  • Include documentation to upload media with tweet (or update avatar/or background image)

Unicode Search CRASH

try to search this

"La dulce niña compró un camión" (Spanish for: the sweet child brought a truck"

Raises a 403 error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.