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
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