Android Question Trouble with Poststring

Christopher

Member
Licensed User
Longtime User
hi,

I am able to access my website with

Dim p As PhoneIntents
StartActivity(p.OpenBrowser("http://www.mysite.com/test.php"))

However I am trying to your Poststring example as follows:

Dim job As HttpJob
job.Initialize("job",Me)

job.Poststring("http://www.mysite.com/test.php","p1=php&p2=MySql")

It does not work and I get a 404 resource not found. Does the above code stand alone or must i include phoneintents and OpenBrowser ?

thanks

Chris
 

KMatle

Expert
Licensed User
Longtime User
The first statement starts your browser with the given site/php to view inside the browser.

Seems you try to use my example. Please put the php in a folder like www.mysite.com/myfolder/test.php:

B4X:
job2.Initialize("Job2", Me)
  job2.PostString("http://www.yourdomain.com/myphp/myscript.php", "p1=php&p2=MySql")

I use "Download2" now (because it handles it better):

B4X:
Dim MyJob As HttpJob
    MyJob.Initialize("MyJob", Me)
    MyJob.download2("http://www.yourdomain.com/myphp/myscript.php", Array As String ("p1", "php", "p2", "MySql"))

Don't forget to put it in quotes "" when it's a constant.
 
Upvote 0

Christopher

Member
Licensed User
Longtime User
thanks . I have made the changes but there's no change. Debug still says requested url not on server . However I can access the webpage from my desktop pc browser (so test.php is present).
 
Upvote 0

Christopher

Member
Licensed User
Longtime User
the log says "where are the variables ?" and a Jobdone routine (a Msgbox) in the code is executed signifying that the job is done.

Chris
 
Upvote 0

Christopher

Member
Licensed User
Longtime User
it seems to work as the jobstring appears in logcat and is good. my php code is below..should I not be getting text on the phone's screen from the print statements ? My phone only shows my msgbox but not the print statements.


<?php

print ("I've have not had the pleasure");

$p1 = $_GET["p1"];
$p2 = $_GET["p2"];

print ("I've received $p1 and $p2");

?>

Thanks
 
Upvote 0

Christopher

Member
Licensed User
Longtime User
i killed the msgbox, but still no print statements.



Sub JobDone(job As HttpJob)

If job.Success Then
Msgbox("this will be fine" , "ok")

Log(job.GetString)

Else
Log("Error: Wey It not working ! " & job.ErrorMessage)
End If
job.Release

End Sub
 
Upvote 0

Christopher

Member
Licensed User
Longtime User
yes,

LogCat connected to: B4A-Bridge: BLU LIFE PLAY-357605050563597
--------- beginning of /dev/log/main
running waiting messages (1)
** Activity (main) Resume **
** Service (service1) Destroy **
** Service (service1) Create **
** Service (service1) Start **
Connected to B4A-Bridge (Wifi)
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: packageoster.b4a
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
where are the variables ?
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: packageoster.b4a
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
where are the variables ?
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Installing file.
PackageAdded: packageoster.b4a
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
where are the variables ?
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
Installing file.
** Activity (main) Pause, UserClosed = false **
PackageAdded: packageoster.b4a
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
where are the variables ?
** Activity (main) Pause, UserClosed = false **
** Activity (main) Pause, UserClosed = false **
Installing file.
PackageAdded: packageoster.b4a
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Form Feedback</title>
</head>
<body>
I've have not had the pleasureI've received php and MySql
</body>
</html>
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Installing file.
Installing file.
PackageAdded: packageoster.b4a
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Form Feedback</title>
</head>
<body>
I've have not had the pleasureI've received php and MySql
</body>
</html>
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Installing file.
Installing file.
PackageAdded: packageoster.b4a
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Form Feedback</title>
</head>
<body>
I've have not had the pleasureI've received php and MySql
</body>
</html>
** Activity (main) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…