# After the step above, you will be redirected to your app's page.
# Create an access token under the the "Your access token" section
ACCESS_KEY=""
ACCESS_SECRET=""

class StdOutListener(StreamListener):
	""" A listener handles tweets are the received from the stream. 
	This is a basic listener that just prints received tweets to stdout.

	"""
	def on_data(self, data):
		with open("results/twitter_data_shopping.txt", "a") as myfile:
			myfile.write('TWEETCOUNT-----------------------------------------------\n')
			myfile.write(data)
			myfile.write('---------------------------------------------------------\n')
		print data # Tweet data [[Insert Function here to pass to backend]
		return True

	def on_error(self, status):
		print status

if __name__ == '__main__':
	l = StdOutListener()
	auth = OAuthHandler(consumer_key, consumer_secret)
	auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)

	# Setting filters for restaurants 
	filters = ['gifts?', 'buy?', 'gifts ?', 'good gifts ?', 'buy ?']
	stream = Stream(auth, l)	
	stream.filter(track=filters)
# Create an access token under the the "Your access token" section
ACCESS_KEY="927740804-8wnkPTouEOuldDh936DxYccoDXM3rVXXIrXidF7F"
ACCESS_SECRET="XYilHfQ4PvRgMuiqc252iK89IYkCV8zsX6n7CIbd2g"

class StdOutListener(StreamListener):
	""" A listener handles tweets are the received from the stream. 
	This is a basic listener that just prints received tweets to stdout.

	"""
	def on_data(self, data):
		with open("results/twitter_data_books.txt", "a") as myfile:
			myfile.write('TWEETCOUNT-----------------------------------------------\n')
			myfile.write(data)
			myfile.write('---------------------------------------------------------\n')
		print data # Tweet data [[Insert Function here to pass to backend]
		return True

	def on_error(self, status):
		print status

if __name__ == '__main__':
	l = StdOutListener()
	auth = OAuthHandler(consumer_key, consumer_secret)
	auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)

	# Setting filters for restaurants 
	filters = ['book ?', 'good books?', 'read?', 'good books', 'books?']
	stream = Stream(auth, l)	
	twitterstream = stream.filter(track=filters)