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

Example 1-3 (Page 5) #7

Closed christhorne closed 13 years ago

christhorne commented 13 years ago

Just got the book today and Example 1-3 does not appear to work on Page 5. I am brand new to python, but it appears that "http://search.twitter.com/trends.json" is no longer a page, or call, that exists. Am I missing something?

Thanks! Chris

christhorne commented 13 years ago

For Example 1-3, it looks like "twitter_search" should = "twitter.Twitter(domain="api.twitter.com") instead. Then the rest of the example code seems to work fine. Found the solution @ http://dev.twitter.com/doc/get/trends.

ptwobrussell commented 13 years ago

Chris - you're right that the URL you pointed out no longer resolves. At some point or another after printing, the trends API was migrated over to api.twitter.com, so try this one: https://api.twitter.com/trends.json

In code, all you have to do with the twitter python package is use the (default) domain keyword param of "api.twitter.com" and you should be in good shape.

I think we corrected this issue in the latest print run (and ebooks) but I should double check since it gave you some troubles.

Regards - Matthew


http://www.linkedin.com/in/ptwobrussell

On Jul 2, 2011, at 5:39 PM, ChrisThorne wrote:

Just got the book today and Example 1-3 does not appear to work on Page 5. I am brand new to python, but it appears that "http://search.twitter.com/trends.json" is no longer a page, or call, that exists. Am I missing something?

Thanks! Chris

Reply to this email directly or view it on GitHub: https://github.com/ptwobrussell/Mining-the-Social-Web/issues/7

ptwobrussell commented 13 years ago

Closing this issue since it does appear that we updated the book. O'Reilly ebook buyers should have long since gotten a free ebook update, and future print runs will also reflect the change.

andyfFreeman-cisco-Kid commented 12 years ago

Looks like api.twitter.com is no longer current.

twitter_search = twitter.Twitter(domain="api.twitter.com") twitter_search.domain 'api.twitter.com' trends = twitter_search.trends()

Traceback (most recent call last): File "<pyshell#17>", line 1, in trends = twitter_search.trends() File "/opt/ActivePython-2.7/lib/python2.7/site-packages/twitter-1.8.0-py2.7.egg/twitter/api.py", line 167, in call return self._handle_response(req, uri, arg_data) File "/opt/ActivePython-2.7/lib/python2.7/site-packages/twitter-1.8.0-py2.7.egg/twitter/api.py", line 182, in _handle_response raise TwitterHTTPError(e, uri, self.format, arg_data) TwitterHTTPError: Twitter sent status 404 for URL: 1/trends.json using parameters: () details: {"errors":[{"message":"Sorry, that page does not exist","code":34}]}

Now from the developer page I see that the new place for grabbing trends is api.twitter.com/1/ . When I try that it still breaks. twitter_search = twitter.Twitter(domain="api.twitter.com/1/") twitter_search.domain 'api.twitter.com/1/' trends = twitter_search.trends()

Traceback (most recent call last): File "<pyshell#20>", line 1, in trends = twitter_search.trends() File "/opt/ActivePython-2.7/lib/python2.7/site-packages/twitter-1.8.0-py2.7.egg/twitter/api.py", line 167, in call return self._handle_response(req, uri, arg_data) File "/opt/ActivePython-2.7/lib/python2.7/site-packages/twitter-1.8.0-py2.7.egg/twitter/api.py", line 182, in _handle_response raise TwitterHTTPError(e, uri, self.format, arg_data) TwitterHTTPError: Twitter sent status 404 for URL: trends.json using parameters: () details: {"errors":[{"message":"Sorry, that page does not exist","code":34}]}