2012-12-26 81 views
0

Possible Duplicate:
Trouble with Twitter API using PythonTwitter的API - 404错误

当我运行下面的Python代码:

import twitter 
twitter_search = twitter.Twitter(domain="search.twitter.com") 
trends = twitter_search.trends() 

我得到以下错误:

Twitter sent status 404 for URL: trends.json using parameters:() 
details: ?VJ-*?/*V???V?M-.NLOU?R 
?/*??Q(?H,Q(
)??+??(?Vd?(?(%?????????YpD 

谁能给我解释一下为什么?

回答

0

我明白了。正确的代码应该是:

import twitter 
twitter_api = twitter.Twitter(domain="api.twitter.com", api_version='1') 
WORLD_WOE_ID = 1 # The Yahoo! Where On Earth ID for the entire world 
world_trends = twitter_api.trends._(WORLD_WOE_ID) # get back a callable 
[ trend for trend in world_trends()[0]['trends'] ] # call the callable and iterate through the trends returned