Hello all Jabaco Gurus in the house!
I need to submit data to a PHP script using the POST method but I cannot figure out for the life of me, how to change the java snippet below to work in the Jabaco enviroment.
The code:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
Dim url As URL
'URLConnection urlConnection;
Dim urlConnection As URLConnection
'DataOutputStream outStream;
Dim outStream As DataOutputStream
'DataInputStream inStream;
'// Build request body
Dim Body As String
Body = "email=" + URLEncoder.encode(Email, "UTF-8") + "&sub=" + URLEncoder.encode(Subject, "UTF-8") + "&mess=" + URLEncoder.encode(Message, "UTF-8")
'// Create connection
url = New URL("http://192.168.1.68/test/POST/post.php");
urlConnection = url.openConnection()
'Tried to conver the code above to Jabaco the above but can't seen to do the ones below
((HttpURLConnection)urlConnection).setRequestMethod("POST");'<--This is the real problem for me!
urlConnection.setDoInput(True)
urlConnection.setDoOutput(True)
urlConnection.setUseCaches(False)
urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
urlConnection.setRequestProperty("Content-Length", ""+ Body.length());
// Create I/O streams
outStream = New DataOutputStream(urlConnection.getOutputStream())
inStream = New DataInputStream(urlConnection.getInputStream())
// Send request
outStream.writeBytes(Body)
outStream.flush()
outStream.close()
|
Please can the experts help me out or better yet give an alternative solution to my problem?
Thanks!