Last active
February 10, 2022 22:25
-
-
Save jrosen48/0747497e40700e570676dae88b255919 to your computer and use it in GitHub Desktop.
access-academic-twitter.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# apply for access to Twitter's academic program: https://developer.twitter.com/en/solutions/academic-research | |
library(academictwitteR) | |
library(rtweet) | |
library(tidytags) # must be installed first with: remotes::install_github("ropensci/tidytags") | |
bearer_token <- "xxx" # Insert bearer token from developer.twitter.com from the your academic account | |
trial <- get_all_tweets("#BAmazonUnion OR #UnionizeAmazon", "2020-01-01T00:00:00Z", "2021-05-01T00:00:00Z", bearer_token, data_path = NULL) | |
# next, these values are also from your academic account | |
# this next step further processes the data using the {rtweet} package; it isn't strictly necessary and it requires a different set of values to authenticate | |
## store api keys (these are fake example values; replace with your own keys from developer.twitter.com) and authenticate via web browser | |
token <- create_token( | |
app = "xxxx", #Name of your app in dashboard | |
consumer_key = "xxx", | |
consumer_secret = "xxx", | |
access_token = "xxx", | |
access_secret = "xxx") | |
get_token() | |
trial_processed <- lookup_statuses(trial$id) | |
# optional: to create an edgelist | |
edgelist <- create_edgelist(trial_processed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment