ptwobrussell / Mining-the-Social-Web

The official online compendium for Mining the Social Web (O'Reilly, 2011)
http://bit.ly/135dHfs
Other
1.21k stars 491 forks source link

Issue with using the Twitter wrapper #1

Closed nsshami closed 13 years ago

nsshami commented 13 years ago

Hi Matthew,

I created an issue with api.py of the Twitter wrapper you suggest to use in the book https://github.com/sixohsix/twitter/issues#issue/35. I hope you can check it out as I'm sure others will encounter the same problem.

Thanks!

ptwobrussell commented 13 years ago

Can you tell me the version of twitter you are using? Is it 1.4.2 as is the default version from PyPi with easy_install or are you using whatever is the latest from GitHub? (I've run into various troubles with the latest from GitHub and recommend the latest stable release, which is 1.4.2.) Also, can you tell me your version of Python and platform? Shouldn't matter but would be helpful.

I'll check into this this evening and report back something more concrete, but haven't run into this issue and I've used the twitter package extensively, so I'm thinking it could very likely be an environment or configuration issue.

nsshami commented 13 years ago

The version of Twitter is 1.4.2-4, which I think I downloaded from github. I am using Python 2.6 and am on Mac OSX Leopard.

Thanks for looking into this!

ptwobrussell commented 13 years ago

Hmm. I'm just not having any luck reproducing this? This is the minimal code that should be necessary to reproduce:

import twitter
from twitter.oauth_dance import oauth_dance

# Go to http://twitter.com/apps/new to create an app 
# to get the consumer key/secret

CONSUMER_KEY = "XXX" # fill in with your own value
CONSUMER_SECRET = "XXX" # fill in with your own value

(oauth_token, oauth_token_secret) = oauth_dance('MiningTheSocialWeb',
        CONSUMER_KEY, CONSUMER_SECRET)

t = twitter.Twitter(domain='api.twitter.com', api_version='1',
                    auth=twitter.oauth.OAuth(oauth_token, oauth_token_secret,
                    CONSUMER_KEY, CONSUMER_SECRET))

My version of twitter is the latest stable:

Godzilla-2:~ matthew$ easy_install -n twitter
Searching for twitter
Best match: twitter 1.4.2
Processing twitter-1.4.2-py2.6.egg
twitter 1.4.2 is already the active version in easy-install.pth
Installing twitter script to /Library/Frameworks/Python.framework/Versions/2.6/bin
Installing twitterbot script to /Library/Frameworks/Python.framework/Versions/2.6/bin
Using /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/twitter-1.4.2-py2.6.egg
Processing dependencies for twitter
Finished processing dependencies for twitter

Can you try this minimal program and if you still have problems report back the full stack and also the result of easy_install -n twitter?

nsshami commented 13 years ago

I still get the same error. Below is the full stack Hi there! We're gonna get you all set up to use MiningTheSocialWeb. Traceback (most recent call last): File "/Users/nsshami/workspace/pythonDevelopment/miningSocialWeb/toy.py", line 11, in CONSUMER_KEY, CONSUMER_SECRET) File "build/bdist.macosx-10.3-fat/egg/twitter/oauth_dance.py", line 26, in oauth_dance File "build/bdist.macosx-10.3-fat/egg/twitter/api.py", line 155, in call File "build/bdist.macosx-10.3-fat/egg/twitter/api.py", line 82, in wrap_response TypeError: str() takes at most 1 argument (2 given)

The results of easy_install -n twitter:

nsshami$ easy_install -n twitter Searching for twitter Best match: twitter 1.4.2 Processing twitter-1.4.2-py2.6.egg twitter 1.4.2 is already the active version in easy-install.pth Installing twitter script to /Library/Frameworks/Python.framework/Versions/2.6/bin Installing twitterbot script to /Library/Frameworks/Python.framework/Versions/2.6/bin Using /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/twitter-1.4.2-py2.6.egg Processing dependencies for twitter Finished processing dependencies for twitter

nsshami commented 13 years ago

btw, github messes up some of the formatting of the stacktrace. but it has most of the content.

nsshami commented 13 years ago

Hi Matthew,

The issue with api.py has been resolved by sixohsix (https://github.com/sixohsix/twitter/issues/35#comment_807366) and I have confirmed that it works with the most recent release (v 1.5).