O'Reilly logo

Play Framework Cookbook - Second Edition by Giancarlo Inductivo, Alexander Reelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the Twitter API and OAuth

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.

How to do it…

For Java, we need to perform the following steps:

  1. Run the foo_java application with Hot-Reloading enabled:
        activator "~run"
    
  2. 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"
  3. Modify the WebClient controller in foo_java/app/controllers/WebClient.java with the following action:
     // Add additional imports at the top section of the class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required