Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example 1.3 (1st Edition) #68

Open
kimskams80 opened this issue Aug 6, 2013 · 3 comments
Open

Example 1.3 (1st Edition) #68

kimskams80 opened this issue Aug 6, 2013 · 3 comments

Comments

@kimskams80
Copy link

With reference to your reply on
#15 (comment)
I am starting a new thread here for example 1.3. It must be noted that I am using 1st edition of this book with Python 2.7.2. This example is on Page 5 of this book.

example:

import twitter
twitter_search = twitter.Twitter(domain="search.twitter.com")
trends = twitter_search.trends()
[ trend['name'] for trend in trends['trends'] ]

First two lines go well but when I type

trends = twitter_search.trends()

it gives following error:

Traceback (most recent call last):
File "(stdin)" line 1 in
File "build\bdist.win-amd64\egg\twitter\api.py" line 204 in call
File "build\bdist.win-amd64\egg\twitter\api.py" line 235 in _handle_response

twitter.api.TwitterHTTPErro"Twitter sent status 410 for URL : 1.1/trends.json using parameters :()

details: {"errors": [{message":The twitter REST API v1 is no longer active. Please migrate to API 1.1. https://dev.twitter.com/docs/api/1.1/overview. code:68}]

A bonus question please: How can I clear the screen of Python Interactive Shell?

@ptwobrussell
Copy link
Owner

Thanks for such a detailed report. The basic problem is that Twitter did indeed change the way that their API worked as indicated by the error message, and you can get updated code for Chapter 1 here: http://nbviewer.ipython.org/urls/raw.github.com/ptwobrussell/Mining-the-Social-Web/master/ipython_notebooks/Chapter1.ipynb

Specifically, see Example 1-3 in that notebook for an updated version of the code that should work for you. Since the code related to Twitter that's in the text of the book will be outdated, be sure to reference the other notebooks from here https://github.com/ptwobrussell/Mining-the-Social-Web#update---march-2013 when exploring those examples. The example files checked into this repository as individual .py files are also updated (but Example 1-3 is an interactive session and not a .py file.)

Let me know if this helps you. I'd really like to see you get past this problem and start having some fun with this.

Also, you may want to consider watching this screencast if you'd like to start using IPython Notebook and the virtual machine, which is part of the second edition: https://www.youtube.com/watch?v=BTyKPMfi_JQ

As for your question - how do you clear the session in an interpreter - you might want to review this SO response - http://stackoverflow.com/questions/517970/how-to-clear-python-interpreter-console

However, I would strongly encourage you to consider using IPython. It's a much better shell that provides lots of enhancements that you will surely benefit from - http://ipython.org/install.html

@Baco23
Copy link

Baco23 commented Feb 2, 2015

Hi @kimskams80 e @ptwobrussell, I'm four days searching for the answer to this error API and only now I see it.
Congratulations kimskams80 to the question and the master Russell, for the answer.
thank you!

@jianjinucdavis
Copy link

@ptwobrussell Thanks a lot for the updates! This helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants