diff --git a/searchtweets/search_tweets.rb b/searchtweets/search_tweets.rb index ab8e1d3..8ebf5dc 100644 --- a/searchtweets/search_tweets.rb +++ b/searchtweets/search_tweets.rb @@ -428,15 +428,18 @@ def make_data_request(query, start_time, end_time, since_id, until_id, max_resul if @write_mode == 'files' #write the file. - #Each 'page' has a start and end time, go get those for generating filename. - - filename = "" - #TODO: just pass in first timestamp: results.first['created_at'] - filename = get_file_name(query, api_response['data']) - - puts "Storing Search API data in file: #{filename}" - File.open("#{@out_box}/#{filename}.json", "w") do |new_file| - new_file.write(api_response.to_json) + if api_response.key?("data") + #Each 'page' has a start and end time, go get those for generating filename. + filename = "" + #TODO: just pass in first timestamp: results.first['created_at'] + filename = get_file_name(query, api_response['data']) + + puts "Storing Search API data in file: #{filename}" + File.open("#{@out_box}/#{filename}.json", "w") do |new_file| + new_file.write(api_response.to_json) + end + else + puts "No Tweets." if @verbose end elsif @write_mode == 'standard_out' #Standard out