Java Reference
In-Depth Information
portfolioName);
Writer out = new OutputStreamWriter(socket.getOutputStream());
out.write("POST /finance/feeds/default/portfolios HTTP/
1.0\r\n");
out.write("Content-Length: " + request.length() + "\r\n");
out.write("Content-Type: application/atom+xml\r\n");
out.write("Authorization: GoogleLogin auth=" + token + "\r\n");
out.write("\r\n");
out.write(request);
System.out.println("\nADD REQUEST BODY:\n" + request);
out.flush();
//Read response off socket input
System.out.println("\nReading ADD PORTFOLIO POST Response...");
InputStream is = socket.getInputStream();
BufferedReader br = new BufferedReader(new
InputStreamReader(is));
String line = "";
//Just print response to console.
while ((line = br.readLine()) != null) {
System.out.println(line);
}
socket.close();
System.out.println("\nAll done.");
}
/**
* Use your existing account to get an auth token for
* this session. You will use the string returned by
* this method in subsequent requests interacting with
* the service.
*/
public String getAuthToken() throws Exception {
System.out.println("Invoking Google to get Auth Token.");
//get an SSL connection
SSLSocket socket = getSecureSocket();
//build request
String query = q("Email", ACCOUNT);
query += "&" + q("Passwd", PASSWORD);
Search WWH ::




Custom Search