Reputation: 36
I am writing the code for listening to the real-time Tweets from a specific list of users (more than 500 users). I read the Tweepy library documentation, and I could not find how to add the user list. Following is my code:
import tweepy
brearer_token = "XXXXXXX-XXXXX"
class tweetListener(tweepy.StreamingClient):
def on_data(self, raw_data):
print(raw_data)
stream = tweetListener(bearer_token=bearer_token)
user_list = ['user_id1', 'user_id2']
stream.filter(user_fields = user_list)
Going through the documentation, I came across that in the filter()
there is a parameter name user_fields
. However, this encountered 400 errors.
Upvotes: 0
Views: 708
Reputation: 5157
The user_fields
parameter of StreamingClient.filter
is used to specify the fields you want for User objects.
Instead, you need to add rules with StreamingClient.add_rules
.
For more information, you can refer to the guide to using StreamingClient
in Tweepy's documentation and the Twitter API guide on building rules for filtered stream.
Upvotes: 0