I have been trying to connect to the Twitter Streaming API, in particular to POST statuses/filter. In my Flask app, I have went through OAuth with Flask-Dance and my GET request for statuses/show is working fine.
However, the POST request I am trying to run in Flask just returns an empty response, absolutely nothing happens. I was wondering if it was something to do with my headers?
@app.route('/tweet-stream', methods=['POST'])
def streamer():
cashtag = request.form['data']
tweet_info = twitter.post('https://stream.twitter.com/1.1/statuses/filter.json',data={"track": cashtag})
print(tweet_info)
result = {"Hello": "Test"}
return json.dumps(result)
I have also tried using Tweepy to no avail,
class MyStreamListener(tweepy.StreamListener):
def on_status(self, status):
print(status.text)
def on_error(self, status_code):
if status_code == 420:
return False
def streamer():
cashtag = request.form['data']
myStreamListener = MyStreamListener()
myStream = tweepy.Stream(auth = api.auth, listener=myStreamListener)
myStream.filter(track=[cashtag])
result = ''
return result
Cashtag in this instance is a string “HMNY”. I have absolutely no idea what I could be doing wrong.
Here is what the dev console says about my headers: