Hi All,
I’m working on a dataset that looks at public profiles on twitter. I’m wondering if there is a way to get mentions of those same users (preferably using r) though one of the APIs. Does anyone have any experience with this? The get_mentions function in rtweet only pulls your own mentions, not those of specific user.
Many thanks!
Sure - any of the search apis will do this, if you specify the screen_name as a keyword: https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/overview
in R rtweet can do searches (but be aware that it has some issues with Premium Search, standard search is fine)
For gathering data i would recommend https://github.com/DocNow/twarc over R - you don’t need to know python, just enough to install and run it. Then R can load the json into a dataframe for analysis later.
1 Like
Thanks so much! Will try it out and report back!
Hi again =) I’m not sure what the following error means? Code and error included below:
twarc --app_auth search blacklivesmatter
–fullarchive app_name
–from_date 2017-11-01
–to_date 2017-11-30
–limit 100 \
tweets.jsonl
Traceback (most recent call last):
File “/usr/local/bin/twarc”, line 33, in
sys.exit(load_entry_point(‘twarc==1.11.0’, ‘console_scripts’, ‘twarc’)())
File “/usr/local/Cellar/twarc/1.11.0/libexec/lib/python3.9/site-packages/twarc/command.py”, line 280, in main
for thing in things:
File “/usr/local/Cellar/twarc/1.11.0/libexec/lib/python3.9/site-packages/twarc/client.py”, line 196, in premium_search
resp = self.get(url, params=params)
File “/usr/local/Cellar/twarc/1.11.0/libexec/lib/python3.9/site-packages/twarc/decorators.py”, line 56, in new_f
resp.raise_for_status()
File “/usr/local/Cellar/twarc/1.11.0/libexec/lib/python3.9/site-packages/requests/models.py”, line 941, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url:
I had to take out the twitter api url for the comment to post.
I realized I configured my app keys wrong previously, but still haven’t gotten the full_archive to work with twarc. I did get the general search api to work with twarc, so its just the full. rtweet is given me a hard time as well.
1 Like
The “Preformatted text” option in the forums formatting will let you post any urls or whatever - maybe that will work?
As for the error in twarc, i would: double check that the environment you created app_name is ok (this should be the environment label not the application name) in https://developer.twitter.com/en/account/environments and then make sure that the Consumer key and secret come from the app listed under App name (the hidden file named .twarc contains the keys)
Also if using sandbox (non paid Premium) the command is:
twarc search blacklivesmatter --fullarchive docnowdev --from_date 2014-08-04 --to_date 2014-08-05 --limit 100 --sandbox > tweets.jsonl
This example assumes that your environment label is docnowdev in https://developer.twitter.com/en/account/environments