I'm using a public api for Xanga to post blog entries. However, there's a step between getting the pretoken and getting the token, in which the

To get a token (which must be POSTED for every action besides logging in and getting a pretoken), I had to:

  1. run the program to get a pretoken
  2. use the pretoken as GET data to open a web page (in a browser)
  3. indicate that I allow this action by clicking an "accept" button on an html form in the browser (this is also the login step.)
  4. after indicating my consent by manually interfacing with the web page, the pretoken can be used to get an actual token. So I run the program again, using the pretoken to get a token


Of course, you see the problem. I'm manually running the program, then running it again. That's not very automated. Of course, I could put the thread to sleep for a few seconds while I perform the task on the browser page, but that's downright inelegant.

What I'd like is for the java program to know what happens on the browser. I imagined that I could just tap into the browser's output, along the lines of:

Java Code:
Process process = Runtime.getRuntime().exec([I][browser][/I] -url [I][url][/I]);
InputStream in = process.getInputStream();
InputStreamReader reader = new InputStreamReader(in);
int i;
while ((i = reader.read()) != -1)[INDENT]System.out.print((char) i);[/INDENT]
However, when I try to read that stream, I don't get anything at all.

Can anyone think of an alternative solution?