Learn R Programming

vosonSML (version 0.27.2)

Authenticate.twitter: Twitter API authentication

Description

Twitter authentication uses OAuth and either requires authorization of the rtweet package rstats2twitter client app by a registered twitter user or twitter app developer API keys as described here: https://developer.twitter.com/en/docs/basics/authentication/overview/oauth.

Usage

# S3 method for twitter
Authenticate(socialmedia, appName, apiKey, apiSecret,
  accessToken, accessTokenSecret, ...)

Arguments

socialmedia

Character string. Identifier for social media API to authenticate, set to "twitter".

appName

Character string. Registered twitter app name associated with the API keys.

apiKey

Character string. API consumer key to authenticate.

apiSecret

Character string. API consumer secret to authenticate.

accessToken

Character string. API access token to authenticate.

accessTokenSecret

Character string. API access token secret to authenticate.

...

Additional parameters passed to function. Not used in this method.

Value

A credential object containing an access token $auth and social media type descriptor $socialmedia set to "twitter". Object has the class names "credential" and "twitter".

Examples

Run this code
# NOT RUN {
# twitter authentication via user authorization of app on their account
# will open a web browser to twitter prompting the user to log in and authorize the app
# apiKey and apiSecret are equivalent to a twitter apps consumer key and secret
twitterAuth <- Authenticate("twitter", appName = "An App",
  apiKey = "xxxxxxxxxxxx", apiSecret = "xxxxxxxxxxxx"
)

# twitter authentication with developer app api keys
myDevKeys <- list(appName = "My App", apiKey = "xxxxxxxxxxxx",
  apiSecret = "xxxxxxxxxxxx", accessToken = "xxxxxxxxxxxx",
  accessTokenSecret = "xxxxxxxxxxxx")

twitterAuth <- Authenticate("twitter", appName = myDevKeys$appName, 
  apiKey = myDevKeys$apiKey, apiSecret = myDevKeys$apiSecret, accessToken = myDevKeys$accessToken, 
  accessTokenSecret = myDevKeys$accessTokenSecret)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab