Voilà trovo alcune perplessità di mia incomprensione... metodo post che esegunon mi piace ma mi chiedo come posso passare parametri ad una query!!!
Questo e quello che scrivo, ma ripeto e solo sperimentale in quanto io vorrei passare paramtri come se fosse un post
B4X:
Dim p1,p2,p3 As String
p1="'ivanomonti@gmail.com'"
p2="'12345'"
p3="'aXZhbm9tb250aUBnbWFpbC5jb20='"
site = "http://www.ivanomonti.eu/Powershopping_api_php_2013/login.php?mail="& p1 & "&password=" & p2 & "&key=" & p3
parameter = ""
hc.Initialize("hc",Me)
hc.PostString(site,parameter)
in RealStudio uso un dictionary per inviare i parametri, ma qui mi trovo leggermente in diffilcoltà, qualche suggerimento.
B4X:
///////////////////// code RealStudio \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
dim sk as new HTTPSocket
dim form As Dictionary
form = New Dictionary
form.Value("mail") = mail
form.Value("password") = password
form.Value("key") = EncodeBase64(key)
ResultQuery = urlstring + "login.php"
sk = new HTTPSocket
sk.ClearRequestHeaders
sk.SetFormData(form) <<<<<< passaggio parametri
sk.Yield = True
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Sub Button2_Click
swiz = 2
Dim p1,p2,p3 As String
p1="'ivanomonti@gmail.com'"
p2="'12345'"
p3="'aXZhbm9tb250aUBnbWFpbC5jb20='"
site = "http://www.ivanomonti.eu/Powershopping_api_php_2013/login.php"
hc.Initialize("hc",Me)
hc.loadUser(site,Array As String("mail", p1, "password", p2, "key", p3))
End Sub
Public Sub loadUser(Link As String, Parameters() As String)
mLink = Link
Dim sb As StringBuilder
sb.Initialize
sb.Append(Link)
If Parameters.Length > 0 Then sb.Append("?")
Dim su As StringUtils
For i = 0 To Parameters.Length - 1 Step 2
If i > 0 Then sb.Append("&")
sb.Append(su.EncodeUrl(Parameters(i), "UTF8")).Append("=")
sb.Append(su.EncodeUrl(Parameters(i + 1), "UTF8"))
Next
req.InitializeGet(sb.ToString)
CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)
End Sub
risultato e sempre No records found ereditato Class httpUtils2 di Erel nella quale non ho ancora capito che cosa è questa stringa SubmitJob che si trova qui CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)
B4X:
Sub JobDone (Job As HttpJob)
ProgressDialogHide
If Job.Success Then
Dim res As String
res = Job.GetString
If res = "No records found" Then
ToastMessageShow(res, True)
Return
End If
Dim parser As JSONParser
parser.Initialize(res)
Dim result As List
result = parser.NextArray 'returns a list with maps
If swiz = 1 Then
populatelistbox(result)
End If
If swiz = 2 Then
populateuser(result)
End If
Else
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Dovrei essere vicino alla soluzione, ma aspetto vostri suggerimenti.