ckoepp/TwitterSearch

KeyError: 'search_metadata'

Closed this issue · 2 comments

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

Sorry got the keys wrong way around! Fail..

Don't worry...happens to me all the time 😄

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