Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package aiss.model.resources;
- import java.io.UnsupportedEncodingException;
- import java.net.URLEncoder;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import org.restlet.resource.ClientResource;
- import aiss.model.omdb.MovieSearch;
- public class OMDbResource {
- private static final String OMDB_API_KEY = "a00dffb4"; // TODO: Change this API KEY for your personal Key
- private static final Logger log = Logger.getLogger(OMDbResource.class.getName());
- public MovieSearch getMovies(String query) throws UnsupportedEncodingException {
- String keyword = URLEncoder.encode(query, "UTF-8");
- // TODO: Perform search in OMDb
- String uri = "http://www.omdbapi.com/?apikey=" + OMDB_API_KEY + "&s=" + keyword;
- log.log(Level.FINE, "OMDB URI: " + uri);
- // http://www.omdbapi.com/?t=Dumbo&y=2019&plot=full
- // http://www.omdbapi.com/?apikey=[yourkey]&
- ClientResource cr = new ClientResource(uri);
- MovieSearch movieSearch = cr.get(MovieSearch.class);
- return movieSearch;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement