ckoepp / TwitterSearch

A Python library to easily iterate tweets found by the Twitter Search API
MIT License
387 stars 112 forks source link

KeyError: 'search_metadata' #1

Closed sleepyxuras91 closed 11 years ago

sleepyxuras91 commented 11 years ago

Seem to be having a problem with your Python Lib

Traceback (most recent call last): File "main.py", line 41, in for tweet in ts.searchTweetsIterable(tso): # this is where the fun actually starts :) File "/usr/local/lib/python2.7/dist-packages/TwitterSearch-0.1-py2.7.egg/TwitterSearch/TwitterSearch.py", line 32, in searchTweetsIte rable self.searchTweets(order) File "/usr/local/lib/python2.7/dist-packages/TwitterSearch-0.1-py2.7.egg/TwitterSearch/TwitterSearch.py", line 50, in searchTweets self.sentSearch(order.createSearchURL()) File "/usr/local/lib/python2.7/dist-packages/TwitterSearch-0.1-py2.7.egg/TwitterSearch/TwitterSearch.py", line 40, in sentSearch if self.response['content']['search_metadata'].get('next_results'): KeyError: 'search_metadata'

Is the error I'm getting using the sample code on your read me (seen below):

from TwitterSearch import * tso = TwitterSearchOrder() # create a TwitterSearchOrder object tso.setKeywords(['hullcompsci']) # can include multipul searches (e.g. for when GGJ or TTG is on) tso.setKeywords(['Guttenberg', 'Doktorarbeit']) tso.setCount(100) # please dear Mr Twitter, give us 100 results per page (this is the default value, I know :P) tso.setLanguage('en') tso.setIncludeEntities(False) # and don't give us all those entity information (this is a default value too)

ts = TwitterSearch( consumer_key = 'censored' consumer_secret = 'censored', access_token = 'censored', access_token_secret = 'censored' )

ts.authenticate()

counter = 0 # just a small counter for tweet in ts.searchTweetsIterable(tso): # this is where the fun actually starts :) counter += 1 print '@%s tweeted: %s' % (tweet['user']['screen_name'], tweet['text'])

print '*\ Found a total of %i tweets' % counter

Thanks

sleepyxuras91 commented 11 years ago

Sorry got the keys wrong way around! Fail..

ckoepp commented 11 years ago

Don't worry...happens to me all the time :smile:

Maybe I should think about a small check to see whether the authentication is working or not...