Omegahat Statistical Computing

Ideas for statistical computing

Twitter API with OAuth2 using R

Posted by omegahat on October 13, 2014

I just put together some code to collect tweets from Twitter’s search API for some students at Davis.  A brief document describing the approach and the code itself is available at https://github.com/duncantl/TwitterOAuth2.git. It is not completely robust, but it does illustrate how to

  • use OAuth2 for the application-only authentication,
  • deal with rate-limiting, and
  • cursor through the result set of a single query.

The OAuth2 approach gives us a higher rate-limit.  There is also code to use the OAuth1.1 mechanism by directly signing the request using the ROAuth package. This is quite simple using the ROAuth:::signRequest() function.

I am not the first to do this and other people have posted aspects of this at various places.  This tries to show all the pieces.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: