com.simpleyql
Class ApiImpl

java.lang.Object
  extended by com.simpleyql.ApiImpl
All Implemented Interfaces:
Api, java.io.Serializable

public class ApiImpl
extends java.lang.Object
implements Api

Implementation for the Yahoo! API object returned by ApiFactory.

Author:
chester
See Also:
ApiFactory, Serialized Form

Constructor Summary
ApiImpl(java.lang.String consumerKey, java.lang.String consumerSecret, java.lang.String servleturl, boolean resultsAsJson, HttpClient httpclient)
          Retrieves an object that can be used to call the API.
 
Method Summary
 void askAuthorization(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String finalUrl)
          Redirects the current user to the authorization page.
 QueryResult query(java.lang.String yql, java.lang.String authdata)
          Sends a YQL request to Yahoo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApiImpl

public ApiImpl(java.lang.String consumerKey,
               java.lang.String consumerSecret,
               java.lang.String servleturl,
               boolean resultsAsJson,
               HttpClient httpclient)
Retrieves an object that can be used to call the API.

Parameters:
consumerKey - Information obtained when you register your application on Yahoo
consumerSecret - Information obtained when you register your application on Yahoo
servleturl - URL that the CallBackServlet is mapped to.
resultsAsJson - If true, API calls will return their results as JSON, otherwise they will return XML.
httpclient - Object that will do the back-end communcations with Yahoo. If null, will default to URLConnectionClient, which is fine for most people.
Method Detail

askAuthorization

public void askAuthorization(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             java.lang.String finalUrl)
                      throws java.io.IOException,
                             OAuthException
Redirects the current user to the authorization page.

It will store OAuth bookkeeping information at the request's session.

At the end of the process, the user will be redirected to finalURL, which will recieve the "authdata" parameter by GET (which should be stored for future use).

Specified by:
askAuthorization in interface Api
Throws:
java.io.IOException
OAuthException

query

public QueryResult query(java.lang.String yql,
                         java.lang.String authdata)
                  throws OAuthException,
                         java.io.IOException
Description copied from interface: Api
Sends a YQL request to Yahoo

Specified by:
query in interface Api
Parameters:
yql - Request formatted as YQL.
Returns:
Response from the API
Throws:
OAuthException
java.io.IOException


Copyright © 2009. All Rights Reserved.