Hi everyone..
I'm new n glad to join this great forum..
Maybe this is a little stupid question but this made me headache for days...
I was able to communicate with server via php with jOkhttputils2 download2 /get, but why Post request never success?
I have
php
the log
why parameter/string 'action' never sent/catch? it's just a simple parameter. but when I use GET request in other sub it works, did I miss something?
Thank a lot
I'm new n glad to join this great forum..
Maybe this is a little stupid question but this made me headache for days...
I was able to communicate with server via php with jOkhttputils2 download2 /get, but why Post request never success?
I have
B4X:
Sub test
Dim Job As HttpJob
Job.Initialize("", Me)
Try
Job.PostString(strURL & "testpost.php","action=test")
Job.GetRequest.SetContentType("")
' Job.PostMultipart(strURL & "post_dil.php",Map1,Null)
' Job.GetRequest.SetContentType("application/json")
' Job.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0")
' Job.GetRequest.SetContentType("application/json")
' Job.GetRequest.Timeout=60
' Job.GetRequest.SetContentEncoding("UTF8")
Wait For (Job) JobDone(Job As HttpJob)
If Job.Success Then
Log(Job.GetString)
Else
Log("error :" & Job.ErrorMessage)
Job.Release
End If
Catch
Job.Release
Log("Error: " & LastException.Message)
' LogError
End Try
End Sub
php
PHP:
<?php
//require 'db.php';
try
{
$JsonString = file_get_contents("php://input");
echo 'aaa ';
echo "a ".$JsonString;
if(isset($_POST['action'])){
echo 'Status: ';
}else
{
echo 'noooooooooooo ';
}
$JsonString = file_get_contents("php://input");
echo 'bbb ';
echo "bb".$JsonString;
}
catch (Exception $e)
{
print json_encode("Failed");
echo '<br />Caught exception: '.$e->getMessage()."\n";
}
?>
the log
why parameter/string 'action' never sent/catch? it's just a simple parameter. but when I use GET request in other sub it works, did I miss something?
Thank a lot