UPDATE: An updated version of this tutorial can be found here.
Using the Twitter API should be an easy thing, but sometimes pictures and simple code can save you that extra 5 minutes. With that, this post goes over how to use the Twitter API to get tweets using R.
First we need Twitter API Access. The following steps will help you set up your twitter account and be able to use the Twitter API.
- Create a twitter account if you do not already have one.
- Go to https://dev.twitter.com/apps and log in with your twitter credentials.
3. Click “Create New App”
4. Fill out the form and agree to the terms. Click on Create your Twitter application. Put your Callback URL as http://localhost:1410.
5. On the next page, click the “Keys and Access Tokens” tab along the top, then scroll all the way down until you see the section “Your Access Token”
6. Click the button “Create My Access Token”.
7. You should have a screen like the following below.
8. Finally we actually get to use the API to get data. Using the following code below, we can get twitter data.
Note: The reason why we supply the access_token and access_secret is described in the setup_twitter_oauth .Rd file.