Oke, Let’s Start
The first ones, you must be got API key and access token
We must have the API key and access token from Twitter. It is very easy. We just need to make the application on Twitter.
- Visit APPS TWITTER and log in using your Twitter account
- Click Create New Apps button.
- After that, Fill the form below correctly.
- Check "Yes, I agree" in the Developer Agreement
- Click Create your Twitter application
- On the Keys tab and Access Tokens, we can see the consumer key (API key) and consumer secret (API secret)
- To get access tokens, click the Create my access token
- Now that, we have obtained all the "secret code" that can be used for the authentication process, the consumer key (API key), consumer secret (API secret), an access token and access token secret.
Install twitteR Packages from GitHubInstall the latest version of R and the twitteR package from GitHub.
install.packages(c("devtools", "rjson", "bit64", "httr"))User guide about how to install the R package can be seen in the article Installing R Package.
Twitter Authentication with RThe process of authentication performed using setup_twitter_oauth() function with the format:
setup_twitter_oauth(api_key, api_secret, access_token, access_token_secret)Use the key and token obtained in the previous step.
When a function is executed, R console will ask you: Use a local file to cache OAuth access credentials between R sessions?. Type 1 or 2.
Congratulations, the authentication process has been successful and then we can extract data from Twitter, for example searching for the latest tweets containing the word 'UII'.
searchTwitter("UII")Twitter search ("UII") By the way for the record, we have to perform the above authentication process at each session of R.
Thank You for Visiting my blog.
Have Fun with How To Get Twitter Authentication using R Article