In this recipe, we will explore how we can use the built-in support of Play 2.0 for OAuth to retrieve tweets from the Twitter API.
For Java, we need to perform the following steps:
Run the
foo_java
application with Hot-Reloading enabled:activator "~run"
Specify your Twitter API information in
foo_java/conf/application.conf
:tw.consumerKey="YOUR TWITTER DEV CONSUMER KEY HERE" tw.consumerSecret="YOUR TWITTER DEV CONSUMER SECRET HERE" tw.accessToken="YOUR TWITTER DEV ACCESS TOKEN HERE" tw.accessTokenSecret="YOUR TWITTER DEV ACCESS TOKEN SECRET HERE"
Modify the
WebClient
controller infoo_java/app/controllers/WebClient.java
with the following action:// Add additional imports at the top section of the class file import play.Play; import play.libs.oauth.OAuth; import play.libs.oauth.OAuth.OAuthCalculator; import play.libs.ws.WSResponse; import java.util.HashMap; import java.util.Iterator; import java...