Skip to first unread message

Ernesto Sastre

unread,
Oct 7, 2017, 4:04:54 PM10/7/17
to MIT App Inventor Forum

Greetings.

I'll divide my issue in three sections: background, problem, the idea , and my attempt:

BACKGROUND:

I am trying to make a login app to a government website  (https://www.sube.gob.ar/login.aspx) through an android  device. Logging to a previously created account on this website allows you to self-manage your SUBE card, which is a  contactless  payment smart card system used for traveling on the public transport services in my country. 
The only feature I really care about this management app is that one to query your current card balance to know beforehand if you need to charge it before taking a bus, etc. Some similar apps have been already created, but they are city-specific. I want to make one for using it in my city.

PROBLEM:
In order to query your balance, you need to login first, which is a problem right now. This is a snapshot of the login page in the web. It consists of your DNI/ID  type, your DNI/ID number, the password of your choice, a login button,  and a Recaptcha test. the DNI/ID type is not necessary to take into account, since it is selected by default the most common one.

After I login I will have this menu, in which I need to select from a droplist the "query balance command" (Consultar Saldo) and hit the "continuar" button:


A pop up window will show displaying your current balance:



THE IDEA: The ideal scenario would be that you input your dni and pass in the app, and after you hit Send(Enviar) a label will show up saying your current balance. For that I guessed you would have to make use of the web component and HTTP Requests, such as  GET and POST, and somehow retrieve the balance figure from the website.







MY ATTEMPT:
My first attempt is to try to login to the website. I tried using the web component to call the methods BuildRequesterData, and PostText to directly fill the forms with the data of my forms but I don't seem to know how to do it. I also placed a webViewer with the homeurl set to the website just to check it out.


Designer view










Block view







These two blocks






corresponds to the  name/value pairs of the content of the forms... I just inspected the code in the web and found the name field of the forms to be these, but I am not sure if it is correct, I'm actually not sure at all:










So, If you could tell me if such a thing is possible or throw me some tips to make it possible ,I would be appreciated. So far I can't get it to work.

Regards













Taifun

unread,
Oct 7, 2017, 5:09:58 PM10/7/17
to MIT App Inventor Forum
I think, you only will be able to access that page if there is an API available (I might be wrong)...
that page uses asp.net https://en.wikipedia.org/wiki/ASP.NET and as far as I know, you can't inject any values like in this example https://puravidaapps.com/inject.php

Taifun

Ernesto Sastre

unread,
Oct 7, 2017, 6:11:12 PM10/7/17
to MIT App Inventor Forum
Oh, I guess I could try looking for the API. Because trying to web-scrap it might not be easy considering there's a recaptcha in-between.

Saša Vukanović

unread,
Oct 9, 2017, 4:54:45 PM10/9/17
to MIT App Inventor Forum
I have similar problem like you -  POST data over Web component and  want to see results in WebViewer
I didn't find solution how to Post data (API call with JSON) over Web component and show result with Get (html logged page) in WebViewer.
That two compenent (Web and WebViever) haven't same session and there is no solution to show html page which I received from server after I logged with Web component.
If WebViewer had possibility to Post data, there will be easy solution to show data, if server send html page.

Taifun

unread,
Oct 9, 2017, 10:08:36 PM10/9/17
to MIT App Inventor Forum
 and there is no solution to show html page which I received from server after I logged with Web component.
store the result as file and use the webviewer to display it
i.e. set Web.SaveResponse to true and use the Web.GotFile event
Taifun

Saša Vukanović

unread,
Oct 10, 2017, 8:49:49 AM10/10/17
to MIT App Inventor Forum
Thank you Taifun for your response.
Web component use Post Text to send username/password and that work. With Web.GotText event I receive response from server in JSON format about user data.
That user data is not important - it's only confirmation that user exist.
After that, I need to send ANOTHER request , GET with another url. Like response, server send html data.

This GET need to be after POST and I didn't find good solution for that - Web.GotText is a event I don't know to distinguish two same event's with different url's (I try to compare url's after catch a event to do diffeerent  tasks )
When I receive html , after GET, server know that user is logged (that session receive special cookie) and user may continue to use site like logged user.
I check this story with Postman and make some Python code (on PC) and play with components and find that same session with received cookie is a key for this.
In Python ,I need to use Selenium to have possiblityto control webdriver , to send POST and after that GET and show a page.
If I save response on some way , and open it with webview (I'm not made that yet in Thunkable because of distinguish events on different requests), I haven't same session and cookie like with Web component.

I read few solutions to send POST data with webviewer generally in Android
https://book2s.com/java/api/android/webkit/webview/posturl-2.html
but there is use some depreceated library  "EncodingUtils" ...   

In this moment I haven't any idea :) for further analyze except to put POST request , on some way , on webview component.
Thank you one more time for your efforts  
 
Reply all
Reply to author
Forward
0 new messages