I know 2 parameters for httpjob. I used the codes below. I received "new_message counts". But how will I see the content of the new message? Job.Getstring gives me only new_message counts (Column 6 in SQL). What about content of new message? (Column 5 in SQL) Do I need to use GetInputStream or something else?
PHP
SQL
COL1 COL2 COL3 COL4 COL5 COL6
msg_id dt_server IMEI side msg status
B4X:
Dim Job3 As HttpJob
Job3.Initialize("Job3", Me)
Job3.Download2("http://www.xxx.com/yyy.php", Array As String("op", "chat_new_messages", "imei", "111111111111")) PARAMETERS???
End Sub
B4X:
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "Job1"
'print the result to the logs
'Log(Job.GetString)
Case "Job3"
'print the result to the log
Log(Job.GetString)
TextViewMessage.Text=Job.GetString
End Select
Else
Log("Error: " & Job.ErrorMessage)
End If
Job.Release
End Sub
PHP
B4X:
if (@$_GET["op"] == "chat_new_messages")
{
$imei = $_GET["imei"];
// get unread messages number
$q = "SELECT * FROM `gs_tracker_chat` WHERE `imei`='".$imei."' AND `side`='S' AND `status`=0";
$r = mysql_query($q);
$msg_num = mysql_numrows($r);
// set messages to delivered
$q = "UPDATE `gs_tracker_chat` SET `status`=1 WHERE `imei`='".$imei."' AND `side`='S' AND `status`=0";
$r = mysql_query($q);
echo $msg_num;
die;
}
SQL
COL1 COL2 COL3 COL4 COL5 COL6
msg_id dt_server IMEI side msg status