Java Reference
In-Depth Information
* uses the Auth token to create a new portfolio, then
* reads the list of portfolios for this user.
* See:
* http://code.google.com/apis/gdata/reference.html
* http://code.google.com/apis/accounts/docs/
AuthForInstalledApps.html#Request
* https://www.google.com/accounts/ClientLogin
*/
public class GoogleFinanceRestClient {
//replace with your account username and password
private static String ACCOUNT = "me@gmail.com";
private static String PASSWORD = "xxx";
//use this to connect to API for auth token
private static String AUTH_URL = "www.google.com";
//use this to interact with API once authorized
private static String FINANCE_URL = "finance.google.com";
//This is a formattable string. You must replace
//the %s to add your title
private static String ATOM_PORTFOLIO_ADD_XML =
"<entry xmlns='http://www.w3.org/2005/Atom' " +
"xmlns:gf='http://schemas.google.com/finance/2007' " +
"xmlns:gd='http://schemas.google.com/g/2005'>" +
"<title type='text'>%s</title>" +
"<gf:portfolioData currencyCode='USD'/></entry>";
public static void main(String... arg) throws Exception {
//Create an instance of this class
GoogleFinanceRestClient client = new GoogleFinanceRestClient();
//authenticate over SSL to get a session token
String token = client.getAuthToken();
//Create a new portfolio
client.addPortfolio(token, "My Restful Portfolio");
//Retrieve list of current portfolios
client.getPortfolios(token);
}
/**
* Retrieve the list of available portfolios for
* the authorized user.
Search WWH ::




Custom Search