Login to the site from android application to extract and analyze information
I am doing a search for networks in Android and am familiar with the basic concepts. However, I recently worked on an application intended for use by my school as a sorting class / assignment. My school uses the following online course: https://parents.mtsd.k12.nj.us/ and I am currently trying to allow students to enter their login credentials in my app which will then try to get their respective information and display it as a grid. However, I never tried to log into the site from an Android app before analyzing the data (I looked at a few similar questions, but I'm still a little confused)
Any help is appreciated!
[edit] After login, I will use import.io to display data on ledgers, there is no api on the website
source to share
If I understand what you explicitly need:
- Connect to site using HttpURLConnection with custom credit details (send request to login page)
- Get cookies from request (my favorite way is to parse the corresponding header field)
- Use the received cookies with HttpURLConnection.setRequestProperty ("Cookie" receivedCookies) and make another request (to the user data page).
- Get input stream
-
Parsing (you can use the jsoup example to get the "html" u document: Document doc = JSoup.parse (stream, null, "");
-
Show data
RECOMMENDATIONS:
Attention:
- all HTTP requests must be made outside the main thread (ui thread) - you can use an async task for this or target service
EDIT for questions:
ask to use Jsoup to handle the connection?
my answer is no!
Jsoup is a PARSER using HttpURLConnection u get full control over the HTTP request , so for example you can handle some selective exceptions or request properties that jsoup is not capable of! in my experience, after a while I start to take apart libraries and learn their basics and use them in my code!
source to share