My question maybe unheard of or may even be impractical. But, I believe it is practical and acceptable.
Problem: PHP request and response in background thread.
Problem constraints:
- You know it uses POST method.
- It has two fields fname and lname as html ids that need to be filled.
- You get response in the same page i.e. index.php .
Pseudocode to solve the problem:
- Open the website in background. Something like openURL("xyz(dot)com");
- Read the data sent in html format.
- Change the value of the fields fname and lname to required fields "Allen" and "Walker."
- Now, submit the fields back to the server. ( Page has a submit button.)
Note: PHP code has a standard if-else check to check for those values. If the field is properly set, it then says "Success" else "Failed"
- Again, get the response sent by the server.
Check if "Success" was returned.
If "success" was returned, UPDATE UI thread for saying "JOB done". Else, "Job failed."
Note: I am not talking about using a WebView. Everything happens via a service or AsyncTask.
Now, this is a simple question, and any ideas or a direction is acceptable.
So, to recap. You have to open a webpage in background, change its field, submit it back and then get the response.
I know we can open a website and get its content. But, I would also like to know if what I said is possible or not. And, I know it is possible. And, that I only lack the knowledge on Java Web API, could you please guide me on this.
Thank You. And, Have a Good day!