How to Login Web Page using HTTP?

rcaridade

Member
Licensed User
Longtime User
Hi,

I'm starting using Basic4Android (bought it today) and need to login to a HTTPS page and after login success need to open a page.

Login page is: https://meu.uzo.pt/login.xml

It has "msisdn" as user and "password" as password. I'm trying like this but it does not seem to work, can someone help me?

Sub Process_Globals
Dim URL As String
URL = "https://meu.uzo.pt/login.xml"

Dim URL2 As String
URL2 = "https://meu.uzo.pt/sms_gratis.xml"

Dim PhoneNumber As String
PhoneNumber = "000000000"

Dim Password As String
Password = "ppppppppp"

Dim HttpClient1 As HttpClient
End Sub

'*******************************************

Sub Globals
End Sub

'*******************************************

Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
'initialize the HttpClient object which is responsible for all communication.
HttpClient1.Initialize("HttpClient1")
End If

Activity.LoadLayout("main")
End Sub

'*******************************************

Sub Activity_Resume
End Sub

'*******************************************

Sub Activity_Pause (UserClosed As Boolean)
End Sub

'*******************************************

Sub btnConnect_Click
Dim request As HttpRequest

request.InitializePost2(URL, ("msisdn=" & PhoneNumber & "&" & "password=" & Password).GetBytes("UTF8"))

'set timeout to 10 seconds
request.Timeout = 10000

If HttpClient1.Execute(request, 1) = False Then

Return

End If

ProgressDialogShow("Calling server...")
End Sub

'*******************************************

Sub btnConnect2_Click
Dim request As HttpRequest

request.InitializeGet(URL2)

request.Timeout = 10000

If HttpClient1.Execute(request, 1) = False Then

Return

End If

ProgressDialogShow("Reading information...")
End Sub

'*******************************************

Sub HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim result As String

Log("ResponseSuccess")

ProgressDialogHide

result = Response.GetString("UTF8")

Log(result)
End Sub

'*******************************************

Sub HttpClient1_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
Log(Reason)
Log(StatusCode)

ProgressDialogHide

msg = "Error connecting to server."

If reason <> Null Then msg = msg & CRLF & Reason

ToastMessageShow (msg, True)
End Sub
 

susu

Well-Known Member
Licensed User
Longtime User
Here the form, you need to deal with it:

<FORM name="flogin" action="../do-login">
<DIV class="blockFormMyUzo floatLeft">
<DIV class="txt colorBlack"><LABEL for="txbUsername">
telem&oacute;vel</LABEL></DIV>
<DIV class="field"><INPUT type="text" id="msisdn" name="msisdn"> </DIV>
</DIV>
<DIV class="blockFormMyUzo floatLeft">
<DIV class="txt colorBlack"><LABEL for="txbPassword">password</LABEL></DIV>
<DIV class="field">
<INPUT type="password" id="password" name="password"></DIV>
</DIV>
</FORM>
 
Upvote 0

rcaridade

Member
Licensed User
Longtime User
That FORM was the place that I tough that I need to work with.

But can you please send me a example how to work with it?

I never worked with web pages login so I really don't know what to do. I been for several hours searching the net but it's difficult to find a solution.

Thanks for your support.
 
Upvote 0

rcaridade

Member
Licensed User
Longtime User
To access the site must use:


h**ps://meu.uzo.pt/do-login?msisdn=2311234112321&password=423423423423

I can use that address directly in browser to access users information.

What is the correct way to implement this?
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Oá RUI(?) benvindo...

Se consegues aceder drectamnte aa tua pagina UZO, usando o endereço que mencionas t, entao basta te usa-lo o webview para abrir a pagina, como se fosse uma pagina "normal"...
qualquer coisa, apita por PM

Hi Rui(?), Welcome

If as you say you can access your UZO ebpage by typing directlu the Https:..... then youjust have to open the webview usin it as a "normal" web page...that should do the trick, no special handling required...
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
PM me details and I will try to help you, I once made something similar imn B4PPc, to logon to this forum, and go throu a few pages in it
 
Upvote 0

rcaridade

Member
Licensed User
Longtime User
I found how to do it.

************************************************

Dim request As HttpRequest


request.InitializePost2(URLlogin,("msisdn=" & NumeroTelefone & "&" & "password=" & Password).GetBytes("UTF8"))

request.Timeout = 10000 'set timeout to 10 seconds

If ClienteHTTP.Execute(request, 1) = False Then Return

ProgressDialogShow("Server Access...")

************************************************

Thanks for your support.
 
Upvote 0
Top