Rotten Tomatoes API Exercise

Objective

In this exercise you will learn how to use an external API to display contextually relevant data

Preparation

  • Read Chapter 8 of The Live Web
  • The Rotten Tomatoes API documentation is here:
  • Create an account with Mashery, if necessary (click the Register link at the top of the API docs)
  • Obtain an API key for Rotten Tomatoes (should be issued automatically if you created a new account)

Exercise

  1. Create a rotten_tomatoes ruleset and register it using KDK.
  2. Define a function in the global block of the ruleset that uses http:get() to interact with the movies.json endpoint of the Rotten Tomatoes API. Be sure to include your API key as the first argument of the query string. Note that if you can't retrieve the data using curl or a browser, your function won't be able to either. 
  3. Use the techniques from Web Rule Exercises and the (Classic) Quickstart for SquareTag, build a SquareTag app that displays a form that asks the user for a movie title. 
  4. The rule that responds to the web:submit event should extract the movie title from the the form data and query the Rotten Tomatoes datasource with the movie title and retrieve the desired information (e.g., critic and audience ratings) from the JSON response using the pick() operator.
  5. The rule should then display the following information on SquareTag: 
    1. Movie thumbnail
    2. Title
    3. Release Year
    4. Synopsis
    5. Critic ratings
    6. and other data you find interesting. 
  6. The data should be nicely formatted and allow the user to type another movie title in at the bottom. 
  7. If the movie isn't found, display a nice error message that returns the title the user put in. 

Notes

  • You should only create the panel on SquareTag once and then modify it's contents as necessary. This is a version of the initialize then populate pattern 

Copyright Picolabs | Licensed under Creative Commons.