Allow input through browser
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:
- run the program to get a pretoken
- use the pretoken as GET data to open a web page (in a browser)
- indicate that I allow this action by clicking an "accept" button on an html form in the browser (this is also the login step.)
- 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:
However, when I try to read that stream, I don't get anything at all.
Process process = Runtime.getRuntime().exec([I][browser][/I] -url [I][url][/I]);
InputStream in = process.getInputStream();
InputStreamReader reader = new InputStreamReader(in);
while ((i = reader.read()) != -1)[INDENT]System.out.print((char) i);[/INDENT]
Can anyone think of an alternative solution?