首页 > 解决方案 > 我如何使用下面的代码发布数据并告诉用户在发送消息时等待

问题描述

我目前正在为 android 使用 b4a

这是出现的错误

enter code here
 ',' expected.`enter code here`


enter code here
Dim j As HttpJob
            j.Initialize("", Me)
            j.PostString($"http://kccug.com/KabojjaApp/RecieveSMS.ashx?customerId=${act}&s=${edtMessage.Text}&d=${getdate(DateTime.Now)}&id=${NewID}&ph=${phone}&f=${sx}"$ )
            Wait For (j) JobDone(j As HttpJob)
            If j.Success Then
                Log(j.GetString)
            End If

enter code here

标签: vb4android

解决方案


You are using j.PostString which sends a post request. However, you are not using it correctly. j.PostString requires a second parameter: the post data. B4A expects you to put in a comma and the second paramter after the url, but you are only giving 1 parameter (the url) to the function. However, looking at your URL, it seems like your backend is handling stuff through GET requests only anyway, not POST. So really, what you should be using is j.Download. Try this code:

Dim j As HttpJob
j.Initialize("", Me)
j.Download($"http://kccug.com/KabojjaApp/RecieveSMS.ashx?customerId=${act}&s=${edtMessage.Text}&d=${getdate(DateTime.Now)}&id=${NewID}&ph=${phone}&f=${sx}"$)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
    Log(j.GetString)
End If

It's exactly the same, but it uses Download instead of PostString.


推荐阅读