Android Question B4A http posString to and php service

victormedranop

Well-Known Member
Licensed User
Longtime User
hi, i have tray many ways to postString to and Php script. but no luck.

i try with soapUI and this is the string generate.

IMEI=f269ad6583b84f7a0&bateria=10&longi=18.449928&lat=-69.975105&altitud=25&orientacion='N'

anyone can share with me.

thanks.

php code
B4X:
if (isset($_POST["IMEI"])) {
        $IMEI= $_POST["IMEI"];
        $bateria= $_POST["bateria"];
        $fecha= date("d/m/y H:i:s");
        $longi= $_POST["longi"];
        $lat= $_POST["lat"];
        $altitud= $_POST["altitud"];
        $orientacion= $_POST["orientacion"];

B4a code1
B4X:
    Dim m As String  = ""
    Dim j As HttpJob
    Log(m)
    j.Initialize("", Me)
    j.PostString("http://gpstracker.nowyouseeme.net/appmovil/index.php"&$"?IMEI=${public_data.imei}&bateria=10&longi=${public_data.longitude}&lat=${public_data.lattitude}&altitud=${public_data.altitud}&orientacion=N"$ ,m)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
    j.Release

B4a code 2
B4X:
    Dim m As String  = $"?IMEI=${public_data.imei}&bateria=10&longi=${public_data.longitude}&lat=${public_data.lattitude}&altitud=${public_data.altitud}&orientacion=N"$
    Dim j As HttpJob
    Log(m)
    j.Initialize("", Me)
    j.PostString("http://gpstracker.nowyouseeme.net/appmovil/index.php",m)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
    j.Release
 

DonManfred

Expert
Licensed User
Longtime User
Everything in the URL is send via GET.
Your post does only send an empty string (code1). All other values are GET Values.

B4X:
    Dim j As HttpJob
    j.Initialize("", Me)
    Dim m As Map = CreateMap("IMEI":"aabbccddeeff","bateria":99,"longi":50.8336968,"lat":6.4410633,"altitud":0,"orientacion":"NW")
    j.PostMultipart("http://gpstracker.nowyouseeme.net/appmovil/index.php",m,Null)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
    j.Release

Logger connected to: 988ad036525346515630
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
aabbccddeeff0 ' Result from website....
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
btw:
For this amount of data you could also use Download2 and rewite your php code to check for GET Values.
B4X:
    Dim j As HttpJob
    j.Initialize("", Me)
    'Dim m As Map = CreateMap("IMEI":"aabbccddeeff","bateria":99,"longi":50.8336968,"lat":6.4410633,"altitud":0,"orientacion":"NW")
    j.Download2("http://gpstracker.nowyouseeme.net/appmovil/index.php",Array As String("IMEI","aabbccddeeff","bateria",99,"longi",50.8336968,"lat",6.4410633,"altitud",0,"orientacion","NW"))
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
    j.Release

PHP:
if (isset($_GET["IMEI"])) {
        $IMEI= $_GET["IMEI"];
        $bateria= $_GET["bateria"];
        $fecha= date("d/m/y H:i:s");
        $longi= $_GET["longi"];
        $lat= $_GET["lat"];
        $altitud= $_GET["altitud"];
        $orientacion= $_GET["orientacion"];
 
Upvote 0
Top