Thank you Igor!
I’ve checked I installed the v2 version.
My code is shown below:
Here is the part of the code which is making the call
search_args = load_credentials("~/.twitter_keys.yaml",
yaml_key="search_tweets_v2",
env_overwrite=True)
query = '(#ClimateChange #GlobalWarming OR climate OR change) lang:en'
start_time = '2021-05-01T00:00:00Z'
end_time = '2021-05-01T00:59:59Z'
max_results = '10'
expansions = 'geo.place_id,author_id,in_reply_to_user_id,referenced_tweets.id,referenced_tweets.id.author_id'
tweetFields = 'author_id,public_metrics,conversation_id,created_at,in_reply_to_user_id,geo,possibly_sensitive,referenced_tweets'
placeFields = 'contained_within,country,country_code,full_name,geo,id,name,place_type'
userFields = 'created_at,id,location,name,protected,public_metrics,url,username,verified,withheld'
query_params = {'query':query ,'start_time':start_time,
'end_time':end_time, 'max_results':max_results,'expansions' : expansions,
'tweet.fields': tweetFields,'user.fields': userFields,
'place.fields': placeFields}
rs = ResultStream(request_parameters=query_params,
max_tweets=30,**search_args) #maxtweets =
print(rs)
tweets = rs.stream()
tweetList = list(tweets)
for tweet in tweetList[:10]:
print(tweet)
And a part of printed results is like below:
Request payload: {'query': '(#ClimateChange #GlobalWarming OR climate OR change) lang:en', 'start_time': '2021-05-01T00:00:00Z', 'end_time': '2021-05-01T00:59:59Z', 'max_results': '10', 'expansions': 'geo.place_id,author_id,in_reply_to_user_id,referenced_tweets.id,referenced_tweets.id.author_id', 'tweet.fields': 'author_id,public_metrics,conversation_id,created_at,in_reply_to_user_id,geo,possibly_sensitive,referenced_tweets', 'user.fields': 'created_at,id,location,name,protected,public_metrics,url,username,verified,withheld', 'place.fields': 'contained_within,country,country_code,full_name,geo,id,name,place_type', 'next_token': 'b26v89c19zqg8o3fostu5ipf2sn3wopnehwpuzsl8h5rx'}
Rate limit hit... Will retry...
Will retry in 4 seconds...
{'possibly_sensitive': False, 'referenced_tweets': [{'type': 'retweeted', 'id': '1388123504151875584'}], 'author_id': '1375413086631337985', 'public_metrics': {'retweet_count': 2907, 'reply_count': 0, 'like_count': 0, 'quote_count': 0}, 'conversation_id': '1388297109376356353', 'created_at': '2021-05-01T00:59:58.000Z', 'text': 'RT @taekookfolder: Some things never change 😭 https://t.co/kY7DMWo3KW', 'id': '1388297109376356353'}
{'possibly_sensitive': False, 'referenced_tweets': [{'type': 'replied_to', 'id': '1387860571375218692'}], 'author_id': '1149876602085527553', 'public_metrics': {'retweet_count': 0, 'reply_count': 0, 'like_count': 0, 'quote_count': 0}, 'conversation_id': '1387860571375218692', 'in_reply_to_user_id': '1912936586', 'created_at': '2021-05-01T00:59:58.000Z', 'text': "@curi0usJack @sickcodes Doesn't The FSF have a better source repo? It would just be faster to cut their incompetence out than wait for them to change. Just remember to bring a towel.", 'id': '1388297109267419139'}
{'possibly_sensitive': False, 'referenced_tweets': [{'type': 'retweeted', 'id': '1388295860899958785'}], 'author_id': '1143667146188345344', 'public_metrics': {'retweet_count': 4159, 'reply_count': 0, 'like_count': 0, 'quote_count': 0}, 'conversation_id': '1388297108889944067', 'created_at': '2021-05-01T00:59:58.000Z', 'text': 'RT @POTUS: It’s been a big month, folks. We hit our goal of 200 million shots, announced the end of America’s longest war, hosted a global…', 'id': '1388297108889944067'}
I am sorry for my late reply.