GABRIEL DOS SANTOS
GABRIEL DOS SANTOS

Reputation: 1

When I try to stream a few few Tweets, I only get the 403 response

I am trying to perform real time sentiment analysis using Twitter, but instead of Tweets I only get the number 403.

from tweepy import Stream, StreamListener
import json 
from textblob import TextBlob
import re
import csv


class Listener(StreamListener):
   def on_data(self, data):
      raw_tweets = json.loads(data)
      print(raw_tweets['text'])

   def on_error(self, status):
      print(status)


auth = tw.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)

twitter_stream = Stream(auth, Listener())
twitter_stream.filter(track = ['Trump'])

When I do this, as said before I only get the number 403 several times.

It is worth mentioning I got elevated access

Upvotes: 0

Views: 264

Answers (2)

Harmon758
Harmon758

Reputation: 5157

New Twitter Developer Apps:

will not be able to gain access to v1.1 statuses/sample and v1.1 statuses/filter

https://twittercommunity.com/t/deprecation-announcement-removing-compliance-messages-from-statuses-filter-and-retiring-statuses-sample-from-the-twitter-api-v1-1/170500

You'll have to use Twitter API v2.

Upvotes: 1

RyloRiz
RyloRiz

Reputation: 87

403 is the HTTP error code for "Forbidden". You can read more about it here:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403

You must be doing something incorrectly when authenticating with the Twitter API.

Upvotes: 0

Related Questions