This vignette introduces the initial setup necessary to use tidytags. Specifically, this guide offers help for two key tasks.
With a TAGS tracker archive imported into R,
tidytags allows you to gather quite a bit more
information related to the TAGS-collected tweets with the
pull_tweet_data()
function. This function builds off the rtweet
package (via rtweet::lookup_tweets()
) to query the
Twitter API. However, to access the Twitter API, whether through
rtweet or tidytags, you will need to apply for developers’ access from
Twitter. You do this through
Twitter’s developer website.
Once approved for developer’s access to the Twitter API, be sure to save the keys and tokens granted to you. These will only be available to you once (but you can easily generate new ones later as needed), so save them in a secure place.
Never share API keys or tokens with anyone; never add these directly to your R code or output.
One option is to save your Twitter API credentials in the
.Renviron file accessed through the
usethis::edit_r_environ(scope='user')
function.
Your saved Twitter API key and tokens should like something like this:
= NameOfYourTwitterApp
TWITTER_APP = YourConsumerKey
TWITTER_API_KEY = YourConsumerSecretKey
TWITTER_API_SECRET = YourAccessToken
TWITTER_ACCESS_TOKEN = YourAccessTokenSecret
TWITTER_ACCESS_TOKEN_SECRET = YourBearerToken
TWITTER_BEARER_TOKEN = YourBearer TWITTER_BEARER
The rtweet documentation already contains a very
thorough vignette, “Authentication with rtweet”
(vignette("auth", package = "rtweet")
), to guide you
through the process of authenticating access to the Twitter API. We
recommend the app-based authentication method that uses
auth <- rtweet::rtweet_app()
, described in the Apps
section of the vignette.
The default for the app-based method is to enter the Twitter bearer token (what you saved as TWITTER_BEARER_TOKEN) interactively, when prompted.
Finally, to make sure the authentication works properly, run the code
rtweet::get_token()
.
tidytags is still a work in progress, so we fully expect that there are still some bugs to work out and functions to document better. If you find an issue, have a question, or think of something that you really wish tidytags would do for you, don’t hesitate to email Bret or reach out on Twitter: @bretsw and @jrosenberg6432.
You can also submit an issue on GitHub.
You may also wish to try some general troubleshooting strategies: